diff --git a/js/ext/angular/src/directive/ionicContent.js b/js/ext/angular/src/directive/ionicContent.js index 151aecf982..c64bce4885 100644 --- a/js/ext/angular/src/directive/ionicContent.js +++ b/js/ext/angular/src/directive/ionicContent.js @@ -42,14 +42,14 @@ angular.module('ionic.ui.content', ['ionic.ui.service', 'ionic.ui.scroll']) * directive, and infinite scrolling with the {@link ionic.directive:ionInfiniteScroll} * directive. * - * @restrict E + * Use the classes 'has-header', 'has-subheader', 'has-footer', and 'has-tabs' + * to modify the positioning of the ion-content relative to surrounding elements. + * + * @param {boolean=} padding Whether to add padding to the content. + * of the content. Defaults to true on iOS, false on Android. * @param {boolean=} scroll Whether to allow scrolling of content. Defaults to true. * @param {boolean=} overflow-scroll Whether to use overflow-scrolling instead of * Ionic scroll. - * @param {boolean=} padding Whether to add padding to the content. - * @param {boolean=} has-header Whether to offset the content for a header bar. - * @param {boolean=} has-subheader Whether to offset the content for a subheader bar. - * @param {boolean=} has-footer Whether to offset the content for a footer bar. * @param {boolean=} has-bouncing Whether to allow scrolling to bounce past the edges * of the content. Defaults to true on iOS, false on Android. * @param {expression=} on-scroll Expression to evaluate when the content is scrolled. @@ -72,10 +72,6 @@ function($parse, $timeout, $controller, $ionicBind) { '
' + '', compile: function(element, attr, transclude) { - if(attr.hasHeader == "true") { element.addClass('has-header'); } - if(attr.hasSubheader == "true") { element.addClass('has-subheader'); } - if(attr.hasFooter == "true") { element.addClass('has-footer'); } - if(attr.hasTabs == "true") { element.addClass('has-tabs'); } if(attr.padding == "true") { element.find('div').addClass('padding'); } return { @@ -103,6 +99,10 @@ function($parse, $timeout, $controller, $ionicBind) { scrollEventInterval: '@' }); + $scope.$watch($attr.padding, function(newVal) { + $element.toggleClass('padding', !!newVal); + }); + if ($scope.scroll === "false") { //do nothing } else if(attr.overflowScroll === "true") { diff --git a/js/ext/angular/test/directive/ionicContent.unit.js b/js/ext/angular/test/directive/ionicContent.unit.js index b8212410da..c191097d27 100644 --- a/js/ext/angular/test/directive/ionicContent.unit.js +++ b/js/ext/angular/test/directive/ionicContent.unit.js @@ -21,11 +21,6 @@ describe('Ionic Content directive', function() { expect(element.hasClass('scroll-content')).toBe(true); }); - it('Has header', function() { - var element = compile('')(scope); - expect(element.hasClass('has-header')).toEqual(true); - }); - it('should add padding classname', function() { var element = compile('')(scope); expect(element.hasClass('scroll-content')).toEqual(true); @@ -34,18 +29,9 @@ describe('Ionic Content directive', function() { expect(scrollElement.hasClass('padding')).toEqual(true); }); - // it('Enables bouncing by default', function() { - // ionic.Platform.setPlatform('iPhone'); - // var element = compile('')(scope); - // scope.$apply(); - // var newScope = element.isolateScope(); - // var scrollView = scope.scrollView; - // expect(scrollView.options.bouncing).toBe(true); - // }); - it('Disables bouncing when has-bouncing = false', function() { ionic.Platform.setPlatform('iPhone'); - var element = compile('')(scope); + var element = compile('')(scope); scope.$apply(); var newScope = element.isolateScope(); var scrollView = scope.scrollView; @@ -54,16 +40,16 @@ describe('Ionic Content directive', function() { it('Disables bouncing by default on Android', function() { ionic.Platform.setPlatform('Android'); - var element = compile('')(scope); + var element = compile('')(scope); scope.$apply(); var newScope = element.isolateScope(); var scrollView = scope.scrollView; expect(scrollView.options.bouncing).toBe(false); }); - it('Disables bouncing by default on Android unless has-bouncing = true', function() { + it('Disables bouncing by default on Android unless', function() { ionic.Platform.setPlatform('Android'); - var element = compile('')(scope); + var element = compile('')(scope); scope.$apply(); var newScope = element.isolateScope(); var scrollView = scope.scrollView; @@ -72,7 +58,7 @@ describe('Ionic Content directive', function() { it('Should set start x and y', function() { - var element = compile('')(scope); + var element = compile('')(scope); scope.$apply(); var newScope = element.isolateScope(); var scrollView = scope.scrollView;