From 9b42ae65f1103a12fca7703975c4fdf77a13a3ee Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Wed, 27 Nov 2013 10:45:44 -0600 Subject: [PATCH] fix .padding for .scroll --- dist/js/ionic-angular.js | 20 ++++++++++++-------- dist/js/ionic.js | 6 +++--- js/ext/angular/src/directive/ionicContent.js | 20 ++++++++++++-------- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index f7a3042c45..30333d9d1a 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -658,16 +658,10 @@ angular.module('ionic.ui.content', []) return function($scope, $element, $attr) { var c = $element.eq(0), - scroll = $element[0].querySelector('.scroll'), clone, sc, - sv; - - if(scroll && attr.padding == "true") { - scroll.classList.add('padding'); - } else if(attr.padding == "true") { - c.addClass('padding'); - } + sv, + addedPadding = false; if(attr.hasHeader == "true") { c.addClass('has-header'); @@ -702,6 +696,10 @@ angular.module('ionic.ui.content', []) } else { sc = document.createElement('div'); sc.className = 'scroll'; + if(attr.padding == "true") { + sc.className += ' padding'; + addedPadding = true; + } $element.append(sc); // Otherwise, supercharge this baby! sv = new ionic.views.Scroll({ @@ -723,6 +721,12 @@ angular.module('ionic.ui.content', []) clone = transclude($scope.$parent); angular.element($element[0].firstElementChild).append(clone); } + + // if padding attribute is true, then add padding if it wasn't added to the .scroll + if(attr.padding == "true" && !addedPadding) { + c.addClass('padding'); + } + }; } }; diff --git a/dist/js/ionic.js b/dist/js/ionic.js index a8b466a593..bc2a115336 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -3232,7 +3232,7 @@ window.ionic = { ionic.extend(this, opts); if(!this.itemHeight && this.listEl) { - this.itemHeight = this.listEl.children[0] && parseInt(this.listEl.children[0].style.height); + this.itemHeight = this.listEl.children[0] && parseInt(this.listEl.children[0].style.height, 10); } ionic.views.ListView.__super__.initialize.call(this, opts); @@ -3294,8 +3294,8 @@ window.ionic = { // Get the first and last elements in the list based on how many can fit // between the pixel range of lowWater and highWater - var first = parseInt(Math.abs(highWater / itemHeight)); - var last = parseInt(Math.abs(lowWater / itemHeight)); + var first = parseInt(Math.abs(highWater / itemHeight), 10); + var last = parseInt(Math.abs(lowWater / itemHeight), 10); // Get the items we need to remove this._virtualItemsToRemove = Array.prototype.slice.call(this.listEl.children, 0, first); diff --git a/js/ext/angular/src/directive/ionicContent.js b/js/ext/angular/src/directive/ionicContent.js index 3be466c87b..ec9e3bd4c4 100644 --- a/js/ext/angular/src/directive/ionicContent.js +++ b/js/ext/angular/src/directive/ionicContent.js @@ -34,16 +34,10 @@ angular.module('ionic.ui.content', []) return function($scope, $element, $attr) { var c = $element.eq(0), - scroll = $element[0].querySelector('.scroll'), clone, sc, - sv; - - if(scroll && attr.padding == "true") { - scroll.classList.add('padding'); - } else if(attr.padding == "true") { - c.addClass('padding'); - } + sv, + addedPadding = false; if(attr.hasHeader == "true") { c.addClass('has-header'); @@ -78,6 +72,10 @@ angular.module('ionic.ui.content', []) } else { sc = document.createElement('div'); sc.className = 'scroll'; + if(attr.padding == "true") { + sc.className += ' padding'; + addedPadding = true; + } $element.append(sc); // Otherwise, supercharge this baby! sv = new ionic.views.Scroll({ @@ -99,6 +97,12 @@ angular.module('ionic.ui.content', []) clone = transclude($scope.$parent); angular.element($element[0].firstElementChild).append(clone); } + + // if padding attribute is true, then add padding if it wasn't added to the .scroll + if(attr.padding == "true" && !addedPadding) { + c.addClass('padding'); + } + }; } };