mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Android back button fixes, closes #454
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
|
||||
## 0.9.23-alpha (pre-release)
|
||||
- Android back button correctly goes back a view or closes the app
|
||||
- CustomEvent polyfill improvements for Android
|
||||
|
||||
|
||||
## 0.9.22 "Alpha Narwhal" (2014-01-30)
|
||||
- Tap polyfill overhaul to remove 300ms delay when firing a click
|
||||
- Android click firing twice fixes
|
||||
|
||||
26
dist/js/ionic-angular.js
vendored
26
dist/js/ionic-angular.js
vendored
@@ -469,8 +469,7 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad', 'ionic.serv
|
||||
};
|
||||
}]);
|
||||
;
|
||||
(function() {
|
||||
'use strict';
|
||||
(function(ionic) {'use strict';
|
||||
|
||||
angular.module('ionic.service.platform', [])
|
||||
|
||||
@@ -495,7 +494,7 @@ angular.module('ionic.service.platform', [])
|
||||
* @param {function} cb the callback to trigger when this event occurs
|
||||
*/
|
||||
onHardwareBackButton: function(cb) {
|
||||
this.ready(function() {
|
||||
ionic.Platform.ready(function() {
|
||||
document.addEventListener('backbutton', cb, false);
|
||||
});
|
||||
},
|
||||
@@ -506,7 +505,7 @@ angular.module('ionic.service.platform', [])
|
||||
* @param {function} fn the listener function that was originally bound.
|
||||
*/
|
||||
offHardwareBackButton: function(fn) {
|
||||
this.ready(function() {
|
||||
ionic.Platform.ready(function() {
|
||||
document.removeEventListener('backbutton', fn);
|
||||
});
|
||||
},
|
||||
@@ -625,8 +624,8 @@ angular.module('ionic.service.templateLoad', [])
|
||||
angular.module('ionic.service.view', ['ui.router'])
|
||||
|
||||
|
||||
.run( ['$rootScope', '$state', '$location', '$document', '$animate',
|
||||
function( $rootScope, $state, $location, $document, $animate) {
|
||||
.run( ['$rootScope', '$state', '$location', '$document', '$animate', '$ionicPlatform',
|
||||
function( $rootScope, $state, $location, $document, $animate, $ionicPlatform) {
|
||||
|
||||
// init the variables that keep track of the view history
|
||||
$rootScope.$viewHistory = {
|
||||
@@ -673,6 +672,21 @@ angular.module('ionic.service.view', ['ui.router'])
|
||||
}
|
||||
});
|
||||
|
||||
// Triggered when devices with a hardware back button (Android) is clicked by the user
|
||||
// This is a Cordova/Phonegap platform specifc method
|
||||
function onHardwareBackButton(e) {
|
||||
if($rootScope.$viewHistory.backView) {
|
||||
// there is a back view, go to it
|
||||
$rootScope.$viewHistory.backView.go();
|
||||
} else {
|
||||
// there is no back view, so close the app instead
|
||||
navigator.app.exitApp();
|
||||
}
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
$ionicPlatform.onHardwareBackButton(onHardwareBackButton);
|
||||
|
||||
}])
|
||||
|
||||
.factory('$ionicViewService', ['$rootScope', '$state', '$location', '$window', '$injector',
|
||||
|
||||
2
dist/js/ionic-angular.min.js
vendored
2
dist/js/ionic-angular.min.js
vendored
File diff suppressed because one or more lines are too long
7
js/ext/angular/src/service/ionicPlatform.js
vendored
7
js/ext/angular/src/service/ionicPlatform.js
vendored
@@ -1,5 +1,4 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
(function(ionic) {'use strict';
|
||||
|
||||
angular.module('ionic.service.platform', [])
|
||||
|
||||
@@ -24,7 +23,7 @@ angular.module('ionic.service.platform', [])
|
||||
* @param {function} cb the callback to trigger when this event occurs
|
||||
*/
|
||||
onHardwareBackButton: function(cb) {
|
||||
this.ready(function() {
|
||||
ionic.Platform.ready(function() {
|
||||
document.addEventListener('backbutton', cb, false);
|
||||
});
|
||||
},
|
||||
@@ -35,7 +34,7 @@ angular.module('ionic.service.platform', [])
|
||||
* @param {function} fn the listener function that was originally bound.
|
||||
*/
|
||||
offHardwareBackButton: function(fn) {
|
||||
this.ready(function() {
|
||||
ionic.Platform.ready(function() {
|
||||
document.removeEventListener('backbutton', fn);
|
||||
});
|
||||
},
|
||||
|
||||
19
js/ext/angular/src/service/ionicView.js
vendored
19
js/ext/angular/src/service/ionicView.js
vendored
@@ -1,8 +1,8 @@
|
||||
angular.module('ionic.service.view', ['ui.router'])
|
||||
|
||||
|
||||
.run( ['$rootScope', '$state', '$location', '$document', '$animate',
|
||||
function( $rootScope, $state, $location, $document, $animate) {
|
||||
.run( ['$rootScope', '$state', '$location', '$document', '$animate', '$ionicPlatform',
|
||||
function( $rootScope, $state, $location, $document, $animate, $ionicPlatform) {
|
||||
|
||||
// init the variables that keep track of the view history
|
||||
$rootScope.$viewHistory = {
|
||||
@@ -49,6 +49,21 @@ angular.module('ionic.service.view', ['ui.router'])
|
||||
}
|
||||
});
|
||||
|
||||
// Triggered when devices with a hardware back button (Android) is clicked by the user
|
||||
// This is a Cordova/Phonegap platform specifc method
|
||||
function onHardwareBackButton(e) {
|
||||
if($rootScope.$viewHistory.backView) {
|
||||
// there is a back view, go to it
|
||||
$rootScope.$viewHistory.backView.go();
|
||||
} else {
|
||||
// there is no back view, so close the app instead
|
||||
navigator.app.exitApp();
|
||||
}
|
||||
e.preventDefault();
|
||||
return false;
|
||||
}
|
||||
$ionicPlatform.onHardwareBackButton(onHardwareBackButton);
|
||||
|
||||
}])
|
||||
|
||||
.factory('$ionicViewService', ['$rootScope', '$state', '$location', '$window', '$injector',
|
||||
|
||||
Reference in New Issue
Block a user