Skip to content

Commit

Permalink
fix(view): don't affect history when inside a modal
Browse files Browse the repository at this point in the history
Closes #1667
  • Loading branch information
ajoslin committed Jul 7, 2014
1 parent 5da1ecd commit b7f45e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions js/angular/directive/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ IonicModule
restrict: 'E',
transclude: true,
replace: true,
controller: [function(){}],
template: '<div class="modal-backdrop">' +
'<div class="modal-wrapper" ng-transclude></div>' +
'</div>'
Expand Down
10 changes: 7 additions & 3 deletions js/angular/directive/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ IonicModule
return {
restrict: 'EA',
priority: 1000,
require: '^?ionNavBar',
require: ['^?ionNavBar', '^?ionModal'],
compile: function(tElement, tAttrs, transclude) {
tElement.addClass('pane');
tElement[0].removeAttribute('title');

return function link($scope, $element, $attr, navBarCtrl) {
if (!navBarCtrl) {
return function link($scope, $element, $attr, ctrls) {
var navBarCtrl = ctrls[0];
var modalCtrl = ctrls[1];

//Don't use the ionView if we're inside a modal or there's no navbar
if (!navBarCtrl || modalCtrl) {
return;
}

Expand Down
10 changes: 9 additions & 1 deletion test/unit/angular/directive/view.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,21 @@ describe('ionView directive', function() {
return el;
}

it('should remove title & add pane, even with no navbar', inject(function($compile, $rootScope) {
it('should only remove title & add pane with no navbar', inject(function($compile, $rootScope) {
var el = $compile('<ion-view title="1">')($rootScope.$new());
$rootScope.$apply();
expect(el.hasClass('pane')).toBe(true);
expect(el[0].getAttribute('title')).toBe(null);
}));

it('should only remove title & add pane in a modal',inject(function($compile, $rootScope) {
var el = $compile('<ion-modal><ion-view title="1"></ion-modal>')($rootScope.$new());
var view = jqLite(el[0].querySelector('.pane'));
$rootScope.$apply();
expect(view.hasClass('pane')).toBe(true);
expect(view[0].getAttribute('title')).toBe(null);
}));

it('should have content inside', function() {
var el = setup(null, null, '<b>some</b> html');
expect(el.html()).toBe('<b>some</b> html');
Expand Down

0 comments on commit b7f45e7

Please sign in to comment.