mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(isActiveScope): find active scope
Find a slide box within a modal within the active tab within a side menu, each history with cached views. Find the active scroll view with multiple tabs. Find a slide box when the modal is attached to the tabs controller.
This commit is contained in:
6
js/angular/directive/sideMenus.js
vendored
6
js/angular/directive/sideMenus.js
vendored
@@ -88,6 +88,12 @@ IonicModule
|
||||
$ionicBody.enableClass(isAsideExposed, 'aside-open');
|
||||
});
|
||||
|
||||
$scope.$on('$ionicView.beforeEnter', function(ev, d){
|
||||
if (d.historyId) {
|
||||
$scope.$activeHistoryId = d.historyId;
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
$ionicBody.removeClass('menu-open', 'aside-open');
|
||||
});
|
||||
|
||||
28
js/angular/service/history.js
vendored
28
js/angular/service/history.js
vendored
@@ -663,13 +663,37 @@ function($rootScope, $state, $location, $window, $timeout, $ionicViewSwitcher, $
|
||||
|
||||
var climbScope = scope;
|
||||
var currentHistoryId = this.currentHistoryId();
|
||||
var foundHistoryId;
|
||||
|
||||
while (climbScope) {
|
||||
if (climbScope.$$disconnected) {
|
||||
return false;
|
||||
}
|
||||
if (currentHistoryId && (currentHistoryId == climbScope.$historyId || currentHistoryId == climbScope.$activeHistoryId)) {
|
||||
return true;
|
||||
|
||||
if (!foundHistoryId && climbScope.hasOwnProperty('$historyId')) {
|
||||
foundHistoryId = true;
|
||||
}
|
||||
|
||||
if (currentHistoryId) {
|
||||
if (climbScope.hasOwnProperty('$historyId') && currentHistoryId == climbScope.$historyId) {
|
||||
return true;
|
||||
}
|
||||
if (climbScope.hasOwnProperty('$activeHistoryId')) {
|
||||
if (currentHistoryId == climbScope.$activeHistoryId) {
|
||||
if (climbScope.hasOwnProperty('$historyId')) {
|
||||
return true;
|
||||
}
|
||||
if (!foundHistoryId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundHistoryId && climbScope.hasOwnProperty('$activeHistoryId')) {
|
||||
foundHistoryId = false;
|
||||
}
|
||||
|
||||
climbScope = climbScope.$parent;
|
||||
}
|
||||
|
||||
|
||||
1
js/angular/service/viewSwitcher.js
vendored
1
js/angular/service/viewSwitcher.js
vendored
@@ -69,6 +69,7 @@ function($timeout, $document, $q, $ionicClickBlock, $ionicConfig, $ionicNavBarDe
|
||||
view = view || {};
|
||||
return {
|
||||
viewId: view.viewId,
|
||||
historyId: view.historyId,
|
||||
stateId: view.stateId,
|
||||
stateName: view.stateName,
|
||||
stateParams: view.stateParams
|
||||
|
||||
@@ -1195,7 +1195,43 @@ describe('Ionic History', function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(ionicHistory.isActiveScope(scope)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should be active when activeHistoryId found before historyId, for tabs controller', function() {
|
||||
ionicHistory.currentView({
|
||||
historyId: '123'
|
||||
});
|
||||
|
||||
var scope = {
|
||||
$parent: {
|
||||
$parent: {
|
||||
$activeHistoryId: '123',
|
||||
$parent: {
|
||||
$historyId: 'xyz'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(ionicHistory.isActiveScope(scope)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should be active when historyId found before activeHistoryId', function() {
|
||||
ionicHistory.currentView({
|
||||
historyId: '123'
|
||||
});
|
||||
|
||||
var scope = {
|
||||
$parent: {
|
||||
$parent: {
|
||||
$activeHistoryId: 'xyz',
|
||||
$parent: {
|
||||
$historyId: '123'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
expect(ionicHistory.isActiveScope(scope)).toEqual(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user