22 * Copyright 2014 Drifty Co.
33 * http://drifty.com/
44 *
5- * Ionic, v0.9.22
5+ * Ionic, v0.9.23-alpha
66 * A powerful HTML5 mobile app framework.
77 * http://ionicframework.com/
88 *
@@ -469,8 +469,7 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
469469 } ;
470470} ] ) ;
471471;
472- ( function ( ) {
473- 'use strict' ;
472+ ( function ( ionic ) { 'use strict' ;
474473
475474angular . module ( 'ionic.service.platform' , [ ] )
476475
@@ -484,18 +483,15 @@ angular.module('ionic.service.platform', [])
484483. provider ( '$ionicPlatform' , function ( ) {
485484
486485 return {
487- setPlatform : function ( p ) {
488- platform = p ;
489- } ,
490- $get : [ '$q' , '$timeout' , function ( $q , $timeout ) {
486+ $get : [ '$q' , function ( $q ) {
491487 return {
492488 /**
493489 * Some platforms have hardware back buttons, so this is one way to bind to it.
494490 *
495491 * @param {function } cb the callback to trigger when this event occurs
496492 */
497493 onHardwareBackButton : function ( cb ) {
498- this . ready ( function ( ) {
494+ ionic . Platform . ready ( function ( ) {
499495 document . addEventListener ( 'backbutton' , cb , false ) ;
500496 } ) ;
501497 } ,
@@ -506,7 +502,7 @@ angular.module('ionic.service.platform', [])
506502 * @param {function } fn the listener function that was originally bound.
507503 */
508504 offHardwareBackButton : function ( fn ) {
509- this . ready ( function ( ) {
505+ ionic . Platform . ready ( function ( ) {
510506 document . removeEventListener ( 'backbutton' , fn ) ;
511507 } ) ;
512508 } ,
@@ -520,17 +516,12 @@ angular.module('ionic.service.platform', [])
520516 * ready.
521517 */
522518 ready : function ( cb ) {
523- var self = this ;
524519 var q = $q . defer ( ) ;
525520
526- $timeout ( function readyWait ( ) {
527- if ( ionic . Platform . isReady ) {
528- q . resolve ( ) ;
529- cb ( ) ;
530- } else {
531- $timeout ( readyWait , 50 ) ;
532- }
533- } , 50 ) ;
521+ ionic . Platform . ready ( function ( ) {
522+ q . resolve ( ) ;
523+ cb ( ) ;
524+ } ) ;
534525
535526 return q . promise ;
536527 }
@@ -622,11 +613,11 @@ angular.module('ionic.service.templateLoad', [])
622613 } ;
623614} ] ) ;
624615;
625- angular . module ( 'ionic.service.view' , [ 'ui.router' ] )
616+ angular . module ( 'ionic.service.view' , [ 'ui.router' , 'ionic.service.platform' ] )
626617
627618
628- . run ( [ '$rootScope' , '$state' , '$location' , '$document' , '$animate' ,
629- function ( $rootScope , $state , $location , $document , $animate ) {
619+ . run ( [ '$rootScope' , '$state' , '$location' , '$document' , '$animate' , '$ionicPlatform' ,
620+ function ( $rootScope , $state , $location , $document , $animate , $ionicPlatform ) {
630621
631622 // init the variables that keep track of the view history
632623 $rootScope . $viewHistory = {
@@ -673,6 +664,21 @@ angular.module('ionic.service.view', ['ui.router'])
673664 }
674665 } ) ;
675666
667+ // Triggered when devices with a hardware back button (Android) is clicked by the user
668+ // This is a Cordova/Phonegap platform specifc method
669+ function onHardwareBackButton ( e ) {
670+ if ( $rootScope . $viewHistory . backView ) {
671+ // there is a back view, go to it
672+ $rootScope . $viewHistory . backView . go ( ) ;
673+ } else {
674+ // there is no back view, so close the app instead
675+ ionic . Platform . exitApp ( ) ;
676+ }
677+ e . preventDefault ( ) ;
678+ return false ;
679+ }
680+ $ionicPlatform . onHardwareBackButton ( onHardwareBackButton ) ;
681+
676682} ] )
677683
678684. factory ( '$ionicViewService' , [ '$rootScope' , '$state' , '$location' , '$window' , '$injector' ,
@@ -1293,7 +1299,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
12931299
12941300// The content directive is a core scrollable content area
12951301// that is part of many View hierarchies
1296- . directive ( 'content' , [ '$parse' , '$timeout' , '$ionicPlatform' , '$ ionicScrollDelegate', function ( $parse , $timeout , $ionicPlatform , $ionicScrollDelegate ) {
1302+ . directive ( 'content' , [ '$parse' , '$timeout' , '$ionicScrollDelegate' , function ( $parse , $timeout , $ionicScrollDelegate ) {
12971303 return {
12981304 restrict : 'E' ,
12991305 replace : true ,
@@ -1358,7 +1364,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
13581364
13591365 // Otherwise, supercharge this baby!
13601366 var hasBouncing = $scope . $eval ( $scope . hasBouncing ) ;
1361- var enableBouncing = ( ! $ionicPlatform . is ( 'Android' ) && hasBouncing !== false ) || hasBouncing === true ;
1367+ var enableBouncing = ( ! ionic . Platform . isAndroid ( ) && hasBouncing !== false ) || hasBouncing === true ;
13621368 // No bouncing by default for Android users, lest they take up pitchforks
13631369 // to our bouncing goodness
13641370 sv = new ionic . views . Scroll ( {
@@ -2756,6 +2762,10 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
27562762 updateHeaderData ( data ) ;
27572763 } ) ;
27582764
2765+ $rootScope . $on ( 'viewState.titleUpdated' , function ( e , data ) {
2766+ $scope . currentTitle = ( data && data . title ? data . title : '' ) ;
2767+ } ) ;
2768+
27592769 // If a nav page changes the left or right buttons, update our scope vars
27602770 $scope . $parent . $on ( 'viewState.leftButtonsChanged' , function ( e , data ) {
27612771 $scope . leftButtons = data ;
@@ -2817,10 +2827,16 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
28172827 $scope . $emit ( 'viewState.rightButtonsChanged' , $scope . rightButtons ) ;
28182828 } ) ;
28192829
2830+ // watch for changes in the title
2831+ var deregTitle = $scope . $watch ( 'title' , function ( val ) {
2832+ $scope . $emit ( 'viewState.titleUpdated' , $scope ) ;
2833+ } ) ;
2834+
28202835 $scope . $on ( '$destroy' , function ( ) {
28212836 // deregister on destroy
28222837 deregLeftButtons ( ) ;
28232838 deregRightButtons ( ) ;
2839+ deregTitle ( ) ;
28242840 } ) ;
28252841
28262842 } ;
0 commit comments