From f577a0414e700fc3d170805b59ed1d4a89cac37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Guiselin?= <jeremy.guiselin@datadoghq.com> Date: Fri, 10 Feb 2017 15:57:10 -0500 Subject: [PATCH] fix wave --- www/js/app.js | 2 +- www/js/pages/football/controller.js | 20 +++++++++++++++++++- www/js/pages/tennis/controller.js | 18 ++++++++++++++++++ www/partials/sport-index.html | 3 +-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 5970383..dc73c3e 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -90,7 +90,7 @@ window.facebookConnectPlugin.logEvent('fb_mobile_first_app_launch'); } - if (ionic.Platform.isIOS()) { + if (ionic.Platform.isIOS() && window.cordova) { window.FirebasePlugin.grantPermission(); } diff --git a/www/js/pages/football/controller.js b/www/js/pages/football/controller.js index 0e8ca87..c27089e 100644 --- a/www/js/pages/football/controller.js +++ b/www/js/pages/football/controller.js @@ -33,6 +33,7 @@ var deregistrationCallbackList = []; var self = this; + self.shouldUp = false; /** End Controller variables @@ -85,7 +86,19 @@ $scope.selected.push(league); $scope.predictionsNumber += league.predictions_number; } - + + var list = angular.element(document.querySelector('#list-packs .list')); + var ionContent = angular.element(document.querySelector('ion-content'))[0]; + + if (self.shouldUp && $scope.selected.length > 0) { + list.css('marginBottom', '50px'); + if (ionContent.scrollTop >= 340) { + ionContent.scrollTop = ionContent.scrollHeight; + } + } else if (self.shouldUp && $scope.selected.length == 0) { + list.css('marginBottom', '0'); + } + var price = self.findPrice($scope.selected.length); $scope.price = price; $scope.$parent.$parent.select($scope.selected, price, $scope.predictionsNumber, 'football', self.findPack($scope.selected.length)); @@ -274,6 +287,11 @@ }); $scope.freePredictions = freePredictions; $scope.leagues = data[1]['data']; + + if ($scope.leagues.length >= 3) { + self.shouldUp = true; + } + if (window.cordova) { self.products = data[2]; } else { diff --git a/www/js/pages/tennis/controller.js b/www/js/pages/tennis/controller.js index a099baf..dbd2a1e 100644 --- a/www/js/pages/tennis/controller.js +++ b/www/js/pages/tennis/controller.js @@ -31,6 +31,7 @@ var deregistrationCallbackList = []; var self = this; + self.shouldUp = false; /** End Controller variables @@ -84,6 +85,18 @@ $scope.predictionsNumber += league.predictions_number; } + var list = angular.element(document.querySelector('#list-packs .list')); + var ionContent = angular.element(document.querySelector('ion-content'))[0]; + + if (self.shouldUp && $scope.selected.length > 0) { + list.css('marginBottom', '50px'); + if (ionContent.scrollTop >= 340) { + ionContent.scrollTop = ionContent.scrollHeight; + } + } else if (self.shouldUp && $scope.selected.length == 0) { + list.css('marginBottom', '0'); + } + var price = self.findPrice($scope.selected.length); $scope.price = price; $scope.$parent.$parent.select($scope.selected, price, $scope.predictionsNumber, 'tennis', self.findPack()); @@ -247,6 +260,11 @@ }); $scope.freePredictions = freePredictions; $scope.leagues = data[1]['data']; + + if ($scope.leagues.length >= 3) { + self.shouldUp = true; + } + if (window.cordova) { self.products = data[2]; } else { diff --git a/www/partials/sport-index.html b/www/partials/sport-index.html index 8a75965..ff4a614 100644 --- a/www/partials/sport-index.html +++ b/www/partials/sport-index.html @@ -4,7 +4,7 @@ </ion-item> </ion-list> <h3 class="title-section" translate="all_predictions"></h3> -<ion-list> +<ion-list id="list-packs"> <ion-item ng-repeat="league in leagues track by league.id" class="pack-item" ng-class="!isBought(league) ? 'locked' : ''"> <a ui-sref="{{getLink(league)}}" ng-click="!isBought(league) ? select(league) : ''"> <img src="img/lock.png" ng-hide="isBought(league)" class="lock" alt=""> @@ -30,4 +30,3 @@ </a> </ion-item> </ion-list> - -- GitLab