var mobirise_swift = angular.module('Mobirise'); // Controller mobirise_swift.controller('OfferGroupsCtrl', function($scope,$http,$attrs,$sce,$rootScope,$timeout) { $scope.init = function() { console.info('Hello from OfferGroupsCtrl'); $scope.httpconfig = { headers:{ 'Authorization': 'Bearer ' + gJWT } }; $scope.displayyoutubevisvir = ('displayyoutubevisvir' in $attrs) ? ($attrs.displayyoutubevisvir == 'true') ? true : false : false; $scope.displayoffers = ('displayoffers' in $attrs) ? ($attrs.displayoffers == 'true') ? true : false : false; $scope.offergroups = []; $scope.swipers = {}; $scope.loadGroups(800,600); }; $scope.loadGroups = function(photowidth,photoheight) { $scope.loadingbusy = true; var url = 'https://lorge.swiftimmo.eu/api/v1/fr/' + gDomainId + '/offergroup?photowidth=' + photowidth + '&photoheight=' + photoheight; //console.log(url); $http.get(url,$scope.httpconfig).then(function (response){ //console.log(success); $scope.loadingbusy = false; if (typeof(response.data.errors) == 'undefined') { $scope.offergroups = response.data; } $timeout(function(){ $scope.offergroups.forEach(function(group){ $scope.buildSwipers(group.ID); $scope.checkVisvir(group); }); $scope.setPhotos(); },100); }); }; $scope.buildSwipers = function(swiperid) { var mySwiper = new Swiper ('#swiper-container-' + swiperid, { // Optional parameters pagination: '#swiper-pagination-' + swiperid, paginationClickable: true, nextButton: '#swiper-button-next-' + swiperid, prevButton: '#swiper-button-prev-' + swiperid, spaceBetween: 30 }); mySwiper.appendSlide('
'); $scope.swipers[swiperid] = mySwiper; }; $scope.setPhotos = function() { $timeout(function() { $scope.offergroups.forEach(function(group){ var swiper = $scope.swipers[group.ID]; for (var i=0;i