Skip to content
Snippets Groups Projects
Commit d3cbf7de authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Join: fix error on swiper initailization

parent 3fc8d5c5
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,11 @@ function JoinChooseAccountTypeModalController($scope, $timeout, UIUtils, csCurre
};
$scope.$on('modal.shown', $scope.load);
$scope.$on("$ionicSlides.sliderInitialized", function(event, data){
// Disable swipe
data.slider.lockSwipes();
});
$scope.slidePrev = function() {
$scope.slides.slider.unlockSwipes();
$scope.slides.slider.slidePrev();
......@@ -107,7 +112,7 @@ function JoinModalController($scope, $state, $interval, $timeout, UIUtils, Crypt
$scope.loading = true;
$scope.isLicenseRead = false;
$scope.isLicenseRead = false;
$scope.showUsername = false;
$scope.showPassword = false;
$scope.formData.computing=false;
......@@ -123,7 +128,7 @@ function JoinModalController($scope, $state, $interval, $timeout, UIUtils, Crypt
$scope.licenseFileUrl = csSettings.getLicenseUrl();
$timeout($scope.listenLicenseRead, 3000);
$scope.startListenLicenseBottom();
$scope.slideBehavior = $scope.computeSlideBehavior();
......@@ -132,6 +137,11 @@ function JoinModalController($scope, $state, $interval, $timeout, UIUtils, Crypt
};
$scope.$on('modal.shown', $scope.load);
$scope.$on("$ionicSlides.sliderInitialized", function(event, data){
// Disable swipe
data.slider.lockSwipes();
});
$scope.slidePrev = function() {
$scope.slides.slider.unlockSwipes();
$scope.slides.slider.slidePrev();
......@@ -344,35 +354,25 @@ function JoinModalController($scope, $state, $interval, $timeout, UIUtils, Crypt
Modals.showHelp({anchor: helpAnchor});
};
$scope.isLicenseOnBottom = function(){
$scope.startListenLicenseBottom = function(){
var iframeEl = angular.element(document.querySelector('.modal #iframe-license'));
iframeEl = iframeEl && iframeEl.length ? iframeEl[0] : undefined;
if (!iframeEl) return false;
var yPos = iframeEl.contentWindow.document.body.scrollTop;
var scrollHeight = iframeEl.contentWindow.document.body.scrollHeight;
var clientHeight = iframeEl.contentWindow.document.body.clientHeight;
if(scrollHeight - clientHeight === yPos){
return true;
if (!iframeEl) {
console.debug('[join] Waiting license frame to be load...');
return $timeout($scope.startListenLicenseBottom, 1000);
}
return false;
};
$scope.listenLicenseRead = function(){
var disableSwipe = false;
$scope.licenseReadInterval = $interval(function(){
// Disable swipe (only once)
if(!disableSwipe){
$scope.slides.slider.lockSwipes();
disableSwipe = true;
}
if($scope.isLicenseOnBottom()){
$scope.licenseBottomInterval = $interval(function(){
var yPos = iframeEl.contentWindow.document.body.scrollTop;
var scrollHeight = iframeEl.contentWindow.document.body.scrollHeight;
var clientHeight = iframeEl.contentWindow.document.body.clientHeight;
var isBottom = (scrollHeight - clientHeight === yPos);
if(isBottom){
$scope.isLicenseRead = true;
$interval.cancel($scope.licenseReadInterval);
$interval.cancel($scope.licenseBottomInterval);
delete $scope.licenseBottomInterval;
}
},1000);
}, 1000);
};
$scope.checkUid = function(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment