@@ -1029,360 +1029,6 @@ angular.module('ionic.ui.loading', [])
10291029( function ( ) {
10301030'use strict' ;
10311031
1032- /**
1033- * Note: currently unused
1034- */
1035-
1036- /**
1037- * @description
1038- * The NavController is a navigation stack View Controller modelled off of
1039- * UINavigationController from Cocoa Touch. With the Nav Controller, you can
1040- * "push" new "pages" on to the navigation stack, and then pop them off to go
1041- * back. The NavController controls a navigation bar with a back button and title
1042- * which updates as the pages switch.
1043- *
1044- * The NavController makes sure to not recycle scopes of old pages
1045- * so that a pop will still show the same state that the user left.
1046- *
1047- * However, once a page is popped, its scope is destroyed and will have to be
1048- * recreated then next time it is pushed.
1049- *
1050- */
1051- angular . module ( 'ionic.ui.nav' , [ 'ionic.service.templateLoad' , 'ionic.service.gesture' , 'ionic.service.platform' , 'ngAnimate' ] )
1052-
1053- . controller ( 'NavCtrl' , [ '$scope' , '$element' , '$animate' , '$compile' , '$timeout' , 'TemplateLoader' , 'Platform' , function ( $scope , $element , $animate , $compile , $timeout , TemplateLoader , Platform ) {
1054- var _this = this ;
1055-
1056- angular . extend ( this , ionic . controllers . NavController . prototype ) ;
1057-
1058- var pushInAnimation = $scope . pushInAnimation || 'slide-in-left' ;
1059- var pushOutAnimation = $scope . pushOutAnimation || 'slide-out-left' ;
1060- var popInAnimation = $scope . popInAnimation || 'slide-in-right' ;
1061- var popOutAnimation = $scope . popOutAnimation || 'slide-out-right' ;
1062-
1063- // Remove some push classnames
1064- var cleanElementAnimations = function ( el ) {
1065- el . removeClass ( pushInAnimation ) ;
1066- el . removeClass ( pushOutAnimation ) ;
1067- el . removeClass ( popInAnimation ) ;
1068- el . removeClass ( popOutAnimation ) ;
1069- }
1070-
1071- /**
1072- * Push a template onto the navigation stack.
1073- * @param {string } templateUrl the URL of the template to load.
1074- */
1075- this . pushFromTemplate = function ( templateUrl ) {
1076- var childScope = $scope . $new ( ) ;
1077- var last = _this . getTopController ( ) ;
1078-
1079- // Load the given template
1080- TemplateLoader . load ( templateUrl ) . then ( function ( templateString ) {
1081-
1082- // Compile the template with the new scope, and append
1083- // it to the navigation's content area
1084- var el = $compile ( templateString ) ( childScope , function ( cloned , scope ) {
1085-
1086- // If there was a last controller, remove it and mark the new
1087- // one to animate
1088- if ( last ) {
1089- // Push animate
1090- cleanElementAnimations ( last . element ) ;
1091- $animate . addClass ( last . element , pushOutAnimation , function ( ) {
1092- last . element [ 0 ] . style . display = 'none' ;
1093- last . element . removeClass ( pushOutAnimation ) ;
1094- } ) ;
1095-
1096- }
1097-
1098-
1099- if ( last ) {
1100- // We will need to animate in the new page since we have an old page
1101- cloned . addClass ( pushInAnimation ) ;
1102- $animate . addClass ( cloned , pushInAnimation ) ;
1103- }
1104-
1105- $animate . enter ( cloned , $element , null , function ( ) {
1106- } ) ;
1107-
1108- } ) ;
1109- } ) ;
1110- } ;
1111-
1112- // Pop function
1113- this . popController = function ( ) {
1114- var last = _this . pop ( ) ;
1115-
1116- var next = _this . getTopController ( ) ;
1117-
1118- if ( last ) {
1119-
1120- cleanElementAnimations ( last . element ) ;
1121- $animate . addClass ( last . element , popOutAnimation , function ( ) {
1122- last . scope . $destroy ( ) ;
1123- last . element . remove ( ) ;
1124- } ) ;
1125- }
1126-
1127- // Animate the next one in
1128- if ( next ) {
1129- cleanElementAnimations ( next . element ) ;
1130- $animate . addClass ( next . element , popInAnimation )
1131- next . element [ 0 ] . style . display = 'block' ;
1132- }
1133-
1134- $scope . $parent . $broadcast ( 'navigation.pop' ) ;
1135- } ;
1136-
1137-
1138- // Extend the low-level navigation controller
1139- // for this angular controller
1140- ionic . controllers . NavController . call ( this , {
1141- content : {
1142- } ,
1143- navBar : {
1144- shouldGoBack : function ( ) {
1145- } ,
1146- show : function ( ) {
1147- this . isVisible = true ;
1148- } ,
1149- hide : function ( ) {
1150- this . isVisible = false ;
1151- } ,
1152- setTitle : function ( title ) {
1153- $scope . navController . title = title ;
1154- } ,
1155- showBackButton : function ( show ) {
1156- } ,
1157- }
1158- } ) ;
1159-
1160- // Support Android hardware back button (native only, not mobile web)
1161- var onHardwareBackButton = function ( e ) {
1162- $scope . $apply ( function ( ) {
1163- _this . popController ( ) ;
1164- } ) ;
1165- }
1166- Platform . onHardwareBackButton ( onHardwareBackButton ) ;
1167-
1168-
1169- this . handleDrag = function ( e ) {
1170- // TODO: Support dragging between pages
1171- } ;
1172-
1173- this . endDrag = function ( e ) {
1174- } ;
1175-
1176- /**
1177- * Push a controller to the stack. This is called by the child
1178- * nav-content directive when it is linked to a scope on the page.
1179- */
1180- $scope . pushController = function ( scope , element ) {
1181- _this . push ( {
1182- scope : scope ,
1183- element : element
1184- } ) ;
1185- $scope . $parent . $broadcast ( 'navigation.push' , scope ) ;
1186- } ;
1187-
1188- this . pushController = function ( scope , element ) {
1189- _this . push ( {
1190- scope : scope ,
1191- element : element
1192- } ) ;
1193- $scope . $parent . $broadcast ( 'navigation.push' , scope ) ;
1194- } ;
1195-
1196- $scope . navController = this ;
1197-
1198- $scope . $on ( '$destroy' , function ( ) {
1199- // Remove back button listener
1200- Platform . offHardwareBackButton ( onHardwareBackButton ) ;
1201- } ) ;
1202- } ] )
1203-
1204- /**
1205- * The main directive for the controller.
1206- */
1207- . directive ( 'navigation' , function ( ) {
1208- return {
1209- restrict : 'E' ,
1210- replace : true ,
1211- transclude : true ,
1212- controller : 'NavCtrl' ,
1213- //templateUrl: 'ext/angular/tmpl/ionicTabBar.tmpl.html',
1214- template : '<div class="view" ng-transclude></div>' ,
1215- scope : {
1216- first : '@' ,
1217- pushAnimation : '@' ,
1218- popAnimation : '@'
1219- } ,
1220- link : function ( $scope , $element , $attr , navCtrl ) {
1221- $scope . pushAnimation = $scope . pushAnimation || 'slide-in-left' ;
1222- $scope . popAnimation = $scope . popAnimation || 'slide-out-left' ;
1223-
1224- if ( $scope . first ) {
1225- navCtrl . pushFromTemplate ( $scope . first ) ;
1226- }
1227- }
1228- } ;
1229- } )
1230-
1231- /**
1232- * Our Nav Bar directive which updates as the controller state changes.
1233- */
1234- . directive ( 'navBar' , function ( ) {
1235- return {
1236- restrict : 'E' ,
1237- require : '^navigation' ,
1238- replace : true ,
1239- scope : {
1240- type : '@' ,
1241- backButtonType : '@' ,
1242- backButtonLabel : '@' ,
1243- backButtonIcon : '@' ,
1244- alignTitle : '@'
1245- } ,
1246- template : '<header class="bar bar-header nav-bar" ng-class="{hidden: !navController.navBar.isVisible}">' +
1247- '<button ng-click="goBack()" class="button" ng-if="navController.controllers.length > 1" ng-class="backButtonType" ng-bind-html="backButtonContent"></button>' +
1248- '<h1 class="title">{{navController.getTopController().scope.title}}</h1>' +
1249- '</header>' ,
1250- link : function ( $scope , $element , $attr , navCtrl ) {
1251- var backButton ;
1252-
1253- $scope . backButtonContent = '' ;
1254-
1255- if ( $scope . backButtonIcon ) {
1256- $scope . backButtonContent += '<i class="icon ' + $scope . backButtonIcon + '"></i>' ;
1257- }
1258- if ( $scope . backButtonLabel ) {
1259- $scope . backButtonContent += ' ' + $scope . backButtonLabel
1260- }
1261-
1262-
1263- $scope . navController = navCtrl ;
1264-
1265- $scope . goBack = function ( ) {
1266- navCtrl . popController ( ) ;
1267- } ;
1268-
1269-
1270- var hb = new ionic . views . HeaderBar ( {
1271- el : $element [ 0 ] ,
1272- alignTitle : $scope . alignTitle || 'center'
1273- } ) ;
1274-
1275- $element . addClass ( $scope . type ) ;
1276-
1277- $scope . headerBarView = hb ;
1278-
1279- $scope . $parent . $on ( 'navigation.push' , function ( ) {
1280- backButton = angular . element ( $element [ 0 ] . querySelector ( '.button' ) ) ;
1281- backButton . addClass ( $scope . backButtonType ) ;
1282- hb . align ( ) ;
1283- } ) ;
1284- $scope . $parent . $on ( 'navigation.pop' , function ( ) {
1285- hb . align ( ) ;
1286- } ) ;
1287-
1288- $scope . $on ( '$destroy' , function ( ) {
1289- //
1290- } ) ;
1291- }
1292- } ;
1293- } )
1294-
1295- . directive ( 'navPage' , [ 'Gesture' , '$animate' , '$compile' , function ( Gesture , $animate , $compile ) {
1296-
1297- return {
1298- restrict : 'AC' ,
1299- require : '^navigation' ,
1300- link : function ( $scope , $element , $attr , navCtrl ) {
1301- var lastParent , lastIndex , childScope , childElement ;
1302-
1303- // Store that we should go forwards on the animation. This toggles
1304- // based on the visibility sequence (to support reverse transitions)
1305- var lastDirection = null ;
1306-
1307- $scope . title = $attr . title ;
1308-
1309- if ( $attr . navBar === "false" ) {
1310- navCtrl . hideNavBar ( ) ;
1311- } else {
1312- navCtrl . showNavBar ( ) ;
1313- }
1314-
1315- $scope . $on ( '$destroy' , function ( ) {
1316- if ( childElement ) {
1317- childElement . remove ( ) ;
1318- }
1319- } ) ;
1320-
1321- // Push this controller onto the stack
1322- navCtrl . pushController ( $scope , $element ) ;
1323- }
1324- }
1325- } ] )
1326-
1327- /**
1328- * Tell the nav controller in the current scope to push a new
1329- * controller onto the stack, with the given template URL.
1330- */
1331- . directive ( 'navPush' , function ( ) {
1332- return {
1333- restrict : 'A' ,
1334- link : function ( $scope , $element , $attr ) {
1335- var templateUrl = $attr . navPush ;
1336-
1337- var pushTemplate = ionic . throttle ( function ( e ) {
1338- $scope . $apply ( function ( ) {
1339- $scope . navController && $scope . navController . pushFromTemplate ( templateUrl ) ;
1340- } ) ;
1341- return false ;
1342- } , 300 , {
1343- trailing : false
1344- } ) ;
1345-
1346- $element . bind ( 'tap' , pushTemplate ) ;
1347-
1348- $scope . $on ( '$destroy' , function ( ) {
1349- $element . unbind ( 'tap' , pushTemplate ) ;
1350- } ) ;
1351- }
1352- }
1353- } )
1354-
1355- /**
1356- * Tell the nav controller in the current scope to pop the top controller
1357- * and go back in the stack.
1358- */
1359- . directive ( 'navPop' , function ( ) {
1360- return {
1361- restrict : 'A' ,
1362- link : function ( $scope , $element , $attr , navCtrl ) {
1363- var popTemplate = ionic . throttle ( function ( e ) {
1364- $scope . $apply ( function ( ) {
1365- $scope . navController && navController . pop ( ) ;
1366- } ) ;
1367- return false ;
1368- } , 300 , {
1369- trailing : false
1370- } ) ;
1371-
1372- $element . bind ( 'tap' , popTemplate ) ;
1373-
1374- $scope . $on ( '$destroy' , function ( ) {
1375- $element . unbind ( 'tap' , popTemplate ) ;
1376- } ) ;
1377- }
1378- }
1379- } )
1380-
1381- } ) ( ) ;
1382- ;
1383- ( function ( ) {
1384- 'use strict' ;
1385-
13861032/**
13871033 * @description
13881034 * The NavController is a navigation stack View Controller modelled off of
0 commit comments