2
2
* Copyright 2014 Drifty Co.
3
3
* http://drifty.com/
4
4
*
5
- * Ionic, v0.9.22
5
+ * Ionic, v0.9.23-alpha
6
6
* A powerful HTML5 mobile app framework.
7
7
* http://ionicframework.com/
8
8
*
@@ -469,8 +469,7 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
469
469
} ;
470
470
} ] ) ;
471
471
;
472
- ( function ( ) {
473
- 'use strict' ;
472
+ ( function ( ionic ) { 'use strict' ;
474
473
475
474
angular . module ( 'ionic.service.platform' , [ ] )
476
475
@@ -484,18 +483,15 @@ angular.module('ionic.service.platform', [])
484
483
. provider ( '$ionicPlatform' , function ( ) {
485
484
486
485
return {
487
- setPlatform : function ( p ) {
488
- platform = p ;
489
- } ,
490
- $get : [ '$q' , '$timeout' , function ( $q , $timeout ) {
486
+ $get : [ '$q' , function ( $q ) {
491
487
return {
492
488
/**
493
489
* Some platforms have hardware back buttons, so this is one way to bind to it.
494
490
*
495
491
* @param {function } cb the callback to trigger when this event occurs
496
492
*/
497
493
onHardwareBackButton : function ( cb ) {
498
- this . ready ( function ( ) {
494
+ ionic . Platform . ready ( function ( ) {
499
495
document . addEventListener ( 'backbutton' , cb , false ) ;
500
496
} ) ;
501
497
} ,
@@ -506,7 +502,7 @@ angular.module('ionic.service.platform', [])
506
502
* @param {function } fn the listener function that was originally bound.
507
503
*/
508
504
offHardwareBackButton : function ( fn ) {
509
- this . ready ( function ( ) {
505
+ ionic . Platform . ready ( function ( ) {
510
506
document . removeEventListener ( 'backbutton' , fn ) ;
511
507
} ) ;
512
508
} ,
@@ -520,17 +516,12 @@ angular.module('ionic.service.platform', [])
520
516
* ready.
521
517
*/
522
518
ready : function ( cb ) {
523
- var self = this ;
524
519
var q = $q . defer ( ) ;
525
520
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
+ } ) ;
534
525
535
526
return q . promise ;
536
527
}
@@ -622,11 +613,11 @@ angular.module('ionic.service.templateLoad', [])
622
613
} ;
623
614
} ] ) ;
624
615
;
625
- angular . module ( 'ionic.service.view' , [ 'ui.router' ] )
616
+ angular . module ( 'ionic.service.view' , [ 'ui.router' , 'ionic.service.platform' ] )
626
617
627
618
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 ) {
630
621
631
622
// init the variables that keep track of the view history
632
623
$rootScope . $viewHistory = {
@@ -673,6 +664,21 @@ angular.module('ionic.service.view', ['ui.router'])
673
664
}
674
665
} ) ;
675
666
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
+
676
682
} ] )
677
683
678
684
. factory ( '$ionicViewService' , [ '$rootScope' , '$state' , '$location' , '$window' , '$injector' ,
@@ -1293,7 +1299,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
1293
1299
1294
1300
// The content directive is a core scrollable content area
1295
1301
// 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 ) {
1297
1303
return {
1298
1304
restrict : 'E' ,
1299
1305
replace : true ,
@@ -1358,7 +1364,7 @@ angular.module('ionic.ui.content', ['ionic.ui.service'])
1358
1364
1359
1365
// Otherwise, supercharge this baby!
1360
1366
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 ;
1362
1368
// No bouncing by default for Android users, lest they take up pitchforks
1363
1369
// to our bouncing goodness
1364
1370
sv = new ionic . views . Scroll ( {
@@ -2756,6 +2762,10 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
2756
2762
updateHeaderData ( data ) ;
2757
2763
} ) ;
2758
2764
2765
+ $rootScope . $on ( 'viewState.titleUpdated' , function ( e , data ) {
2766
+ $scope . currentTitle = ( data && data . title ? data . title : '' ) ;
2767
+ } ) ;
2768
+
2759
2769
// If a nav page changes the left or right buttons, update our scope vars
2760
2770
$scope . $parent . $on ( 'viewState.leftButtonsChanged' , function ( e , data ) {
2761
2771
$scope . leftButtons = data ;
@@ -2817,10 +2827,16 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
2817
2827
$scope . $emit ( 'viewState.rightButtonsChanged' , $scope . rightButtons ) ;
2818
2828
} ) ;
2819
2829
2830
+ // watch for changes in the title
2831
+ var deregTitle = $scope . $watch ( 'title' , function ( val ) {
2832
+ $scope . $emit ( 'viewState.titleUpdated' , $scope ) ;
2833
+ } ) ;
2834
+
2820
2835
$scope . $on ( '$destroy' , function ( ) {
2821
2836
// deregister on destroy
2822
2837
deregLeftButtons ( ) ;
2823
2838
deregRightButtons ( ) ;
2839
+ deregTitle ( ) ;
2824
2840
} ) ;
2825
2841
2826
2842
} ;
0 commit comments