mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
update how view's set titles, closes #337
This commit is contained in:
23
dist/js/ionic-angular.js
vendored
23
dist/js/ionic-angular.js
vendored
@@ -913,11 +913,6 @@ angular.module('ionic.service.view', ['ui.router'])
|
||||
}
|
||||
opts.parentElement.append(opts.enteringElement);
|
||||
}
|
||||
|
||||
$rootScope.$broadcast('viewState.viewEnter', {
|
||||
title: (opts.enteringScope ? opts.enteringScope.title : null),
|
||||
navDirection: (opts.navDirection ? opts.navDirection : null)
|
||||
});
|
||||
|
||||
function getAnimationClass(){
|
||||
// go up the ancestors looking for an animation value
|
||||
@@ -1995,7 +1990,7 @@ angular.module('ionic.ui.slideBox', [])
|
||||
showPager: '@',
|
||||
disableScroll: '@',
|
||||
onSlideChanged: '&',
|
||||
activeSlide: '='
|
||||
activeSlide: '=?'
|
||||
},
|
||||
controller: ['$scope', '$element', function($scope, $element) {
|
||||
var _this = this;
|
||||
@@ -2550,12 +2545,9 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$element.addClass($scope.type);
|
||||
|
||||
var updateHeaderData = function(data) {
|
||||
var oldTitle = $scope.currentTitle;
|
||||
$scope.oldTitle = oldTitle;
|
||||
$scope.oldTitle = $scope.currentTitle;
|
||||
|
||||
if(typeof data.title !== 'undefined') {
|
||||
$scope.currentTitle = data.title;
|
||||
}
|
||||
$scope.currentTitle = (data && data.title ? data.title : '');
|
||||
|
||||
$scope.leftButtons = data.leftButtons;
|
||||
$scope.rightButtons = data.rightButtons;
|
||||
@@ -2573,7 +2565,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$element[0].classList.remove('reverse');
|
||||
}
|
||||
|
||||
animate($scope, $element, oldTitle, data, function() {
|
||||
animate($scope, $element, $scope.oldTitle, data, function() {
|
||||
hb.align();
|
||||
});
|
||||
} else {
|
||||
@@ -2622,6 +2614,12 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
tElement[0].removeAttribute('title');
|
||||
|
||||
return function link($scope, $element, $attr) {
|
||||
|
||||
$rootScope.$broadcast('viewState.viewEnter', {
|
||||
title: $scope.title,
|
||||
navDirection: $scope.$navDirection || $scope.$parent.$navDirection
|
||||
});
|
||||
|
||||
// Should we hide a back button when this tab is shown
|
||||
$scope.hideBackButton = $scope.$eval($scope.hideBackButton);
|
||||
if($scope.hideBackButton) {
|
||||
@@ -2769,6 +2767,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
current = $state.current;
|
||||
|
||||
viewScope = current.scope = scope.$new();
|
||||
viewScope.$navDirection = transitionOptions.navDirection;
|
||||
|
||||
if (locals.$$controller) {
|
||||
locals.$scope = viewScope;
|
||||
|
||||
4
dist/js/ionic-angular.min.js
vendored
4
dist/js/ionic-angular.min.js
vendored
File diff suppressed because one or more lines are too long
6
dist/js/ionic.min.js
vendored
6
dist/js/ionic.min.js
vendored
File diff suppressed because one or more lines are too long
16
js/ext/angular/src/directive/ionicViewState.js
vendored
16
js/ext/angular/src/directive/ionicViewState.js
vendored
@@ -102,12 +102,9 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$element.addClass($scope.type);
|
||||
|
||||
var updateHeaderData = function(data) {
|
||||
var oldTitle = $scope.currentTitle;
|
||||
$scope.oldTitle = oldTitle;
|
||||
$scope.oldTitle = $scope.currentTitle;
|
||||
|
||||
if(typeof data.title !== 'undefined') {
|
||||
$scope.currentTitle = data.title;
|
||||
}
|
||||
$scope.currentTitle = (data && data.title ? data.title : '');
|
||||
|
||||
$scope.leftButtons = data.leftButtons;
|
||||
$scope.rightButtons = data.rightButtons;
|
||||
@@ -125,7 +122,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
$element[0].classList.remove('reverse');
|
||||
}
|
||||
|
||||
animate($scope, $element, oldTitle, data, function() {
|
||||
animate($scope, $element, $scope.oldTitle, data, function() {
|
||||
hb.align();
|
||||
});
|
||||
} else {
|
||||
@@ -174,6 +171,12 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
tElement[0].removeAttribute('title');
|
||||
|
||||
return function link($scope, $element, $attr) {
|
||||
|
||||
$rootScope.$broadcast('viewState.viewEnter', {
|
||||
title: $scope.title,
|
||||
navDirection: $scope.$navDirection || $scope.$parent.$navDirection
|
||||
});
|
||||
|
||||
// Should we hide a back button when this tab is shown
|
||||
$scope.hideBackButton = $scope.$eval($scope.hideBackButton);
|
||||
if($scope.hideBackButton) {
|
||||
@@ -321,6 +324,7 @@ angular.module('ionic.ui.viewState', ['ionic.service.view', 'ionic.service.gestu
|
||||
current = $state.current;
|
||||
|
||||
viewScope = current.scope = scope.$new();
|
||||
viewScope.$navDirection = transitionOptions.navDirection;
|
||||
|
||||
if (locals.$$controller) {
|
||||
locals.$scope = viewScope;
|
||||
|
||||
5
js/ext/angular/src/service/ionicView.js
vendored
5
js/ext/angular/src/service/ionicView.js
vendored
@@ -357,11 +357,6 @@ angular.module('ionic.service.view', ['ui.router'])
|
||||
}
|
||||
opts.parentElement.append(opts.enteringElement);
|
||||
}
|
||||
|
||||
$rootScope.$broadcast('viewState.viewEnter', {
|
||||
title: (opts.enteringScope ? opts.enteringScope.title : null),
|
||||
navDirection: (opts.navDirection ? opts.navDirection : null)
|
||||
});
|
||||
|
||||
function getAnimationClass(){
|
||||
// go up the ancestors looking for an animation value
|
||||
|
||||
@@ -21,6 +21,16 @@ describe('Ionic View', function() {
|
||||
expect(element.hasClass('pane')).toEqual(true);
|
||||
});
|
||||
|
||||
it('should broacast view enter on link', function() {
|
||||
spyOn(scope, '$broadcast');
|
||||
var element = compile('<view title="\'Me Title\'"></view>')(scope);
|
||||
expect(scope.$broadcast).toHaveBeenCalledWith('viewState.viewEnter', { title: 'Me Title', navDirection: undefined });
|
||||
|
||||
scope.$navDirection = 'forward';
|
||||
element = compile('<view title="\'Me Title\'"></view>')(scope);
|
||||
expect(scope.$broadcast).toHaveBeenCalledWith('viewState.viewEnter', { title: 'Me Title', navDirection: 'forward' });
|
||||
});
|
||||
|
||||
it('should set hide back button', function() {
|
||||
spyOn(scope, '$broadcast');
|
||||
|
||||
|
||||
@@ -779,12 +779,9 @@ describe('Ionic View Service', function() {
|
||||
opts.leavingElement = opts.parentElement.find('leaving');
|
||||
opts.enteringElement = $compile("<entering>entering</entering>")(rootScope);
|
||||
|
||||
spyOn(rootScope, '$broadcast');
|
||||
expect(opts.parentElement.html()).toContain("leaving");
|
||||
viewService.transition(opts);
|
||||
expect(opts.parentElement.html()).toContain("entering");
|
||||
|
||||
expect(rootScope.$broadcast).toHaveBeenCalledWith('viewState.viewEnter', { title: null, navDirection: null });
|
||||
}));
|
||||
|
||||
it('should add the animation classname', inject(function($compile) {
|
||||
|
||||
@@ -83,8 +83,9 @@
|
||||
</script>
|
||||
|
||||
<script id="contact.html" type="text/ng-template">
|
||||
<view title="'Contact'" hide-back-button="true">
|
||||
<view hide-back-button="true">
|
||||
<content has-header="true" padding="true">
|
||||
<p>The view's title is blank on purpose.</p>
|
||||
<p>The hideBackButton attribute is "true" for this view.</p>
|
||||
<p>@drifty</p>
|
||||
<p class="text-center">
|
||||
|
||||
Reference in New Issue
Block a user