diff --git a/js/ext/angular/src/directive/ionicSideMenu.js b/js/ext/angular/src/directive/ionicSideMenu.js index 5f9e48c08a..0fbfd269f1 100644 --- a/js/ext/angular/src/directive/ionicSideMenu.js +++ b/js/ext/angular/src/directive/ionicSideMenu.js @@ -315,5 +315,36 @@ angular.module('ionic.ui.sideMenu', ['ionic.service.gesture', 'ionic.service.vie }; } }; -}); +}) + + +/** + * @ngdoc directive + * @name menuClose + * @module ionic + * @restrict AC + * + * @description + * Closes a side menu which is currently opened. + * + * @usage + * Below is an example of a link within a side menu. Tapping this link would + * automatically close the currently opened menu + * + * ```html + * Home + * ``` + */ +.directive('menuClose', ['$ionicViewService', function($ionicViewService) { + return { + restrict: 'AC', + require: '^ionSideMenus', + link: function($scope, $element, $attr, sideMenuCtrl) { + $element.bind('click', function(){ + sideMenuCtrl.close(); + }); + } + }; +}]); + })(); diff --git a/js/ext/angular/src/directive/ionicViewState.js b/js/ext/angular/src/directive/ionicViewState.js index 39bfbbd8f7..cc14537246 100644 --- a/js/ext/angular/src/directive/ionicViewState.js +++ b/js/ext/angular/src/directive/ionicViewState.js @@ -272,6 +272,40 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu } }; return directive; +}]) + + +/** + * @ngdoc directive + * @name navClear + * @module ionic + * @restrict AC + * + * @description + * Disables any transition animations between views, along with removing the back + * button which would normally show on the next view. This directive is useful for + * links within a sideMenu. + * + * @usage + * Below is an example of a link within a side menu. Tapping this link would disable + * any animations which would normally occur between views. + * + * ```html + * Home + * ``` + */ +.directive('navClear', ['$ionicViewService', function($ionicViewService) { + return { + restrict: 'AC', + link: function($scope, $element, $attr) { + $element.bind('click', function(){ + $ionicViewService.nextViewOptions({ + disableAnimate: true, + disableBack: true + }); + }); + } + }; }]); })(); diff --git a/js/ext/angular/src/service/ionicView.js b/js/ext/angular/src/service/ionicView.js index e1fabea1c6..0ba8085f15 100644 --- a/js/ext/angular/src/service/ionicView.js +++ b/js/ext/angular/src/service/ionicView.js @@ -124,6 +124,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) currentView = viewHistory.currentView, backView = viewHistory.backView, forwardView = viewHistory.forwardView, + nextViewOptions = this.nextViewOptions(), rsp = { viewId: null, navAction: null, @@ -159,7 +160,7 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) rsp.navAction = 'moveBack'; rsp.viewId = backView.viewId; //when going back, erase scrollValues - currentView.rememberedScrollValues = {}; + currentView.rememberedScrollValues = {}; if(backView.historyId === currentView.historyId) { // went back in the same history rsp.navDirection = 'back'; @@ -240,6 +241,12 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) hist.stack.push(viewHistory.views[rsp.viewId]); } + if(nextViewOptions) { + if(nextViewOptions.disableAnimate) rsp.navDirection = null; + if(nextViewOptions.disableBack) viewHistory.views[rsp.viewId].backViewId = null; + this.nextViewOptions(null); + } + this.setNavViews(rsp.viewId); hist.cursor = viewHistory.currentView.index; @@ -389,6 +396,14 @@ angular.module('ionic.service.view', ['ui.router', 'ionic.service.platform']) return { historyId: 'root', scope: $rootScope }; }, + nextViewOptions: function(opts) { + if(arguments.length) { + this._nextOpts = opts; + } else { + return this._nextOpts; + } + }, + getRenderer: function(navViewElement, navViewAttrs, navViewScope) { var service = this; var registerData; diff --git a/js/ext/angular/test/sideMenu.html b/js/ext/angular/test/sideMenu.html index ae4fb4852b..df370727cf 100644 --- a/js/ext/angular/test/sideMenu.html +++ b/js/ext/angular/test/sideMenu.html @@ -2,21 +2,21 @@ Side Menus - - - +
+ + -
- +
+

Slide me

- +
Hello @@ -38,8 +38,9 @@ + -
+

Right

@@ -50,29 +51,27 @@ + +
diff --git a/js/ext/angular/test/sideMenu2.html b/js/ext/angular/test/sideMenu2.html index cc52b872a8..08d7202b47 100644 --- a/js/ext/angular/test/sideMenu2.html +++ b/js/ext/angular/test/sideMenu2.html @@ -16,7 +16,7 @@ - @@ -28,8 +28,8 @@
- Check-in - Attendees + Check-in + Attendees
Range
@@ -43,7 +43,7 @@ -
+
Right Menu
@@ -52,7 +52,7 @@