var mobirise_swift = angular.module('Mobirise'); // Controller mobirise_swift.controller('OwnerCtrl', function($scope,$http,$attrs,$window,$rootScope,$timeout,$sce) { $scope.init = function() { console.info('Hello from OwnerCtrl'); $scope.httpconfig = { headers:{ 'Authorization': 'Bearer ' + gJWT } }; $scope.userid = parseInt('{user::id}'); $scope.userfirstname = '{user::firstname}'; $scope.userlastname = '{user::lastname}'; if ($scope.userid == -1) { var ownerpage = '{owner::login}'; window.location.href = ownerpage; } $scope.offers = []; $scope.swipers = {}; $scope.historystart = 0; $scope.historylimit = 5; $scope.owneroffers(800,600); } $scope.owneroffers = function(width,height) { $http.get('https://housingimmo.be/api/v1/fr/' + gDomainId + '/contact/' + $scope.userid + '/owner/offer?photowidth=' + width + '&photoheight=' + height,$scope.httpconfig).then(function (response){ $scope.loadingbusy = false; if (typeof(response.data.errors) == 'undefined') { $scope.offers = response.data; } $timeout(function(){ $scope.offers.forEach(function(offer){ $scope.buildSwipers(offer.ID); }); $scope.setPhotos(); },100); }); } $scope.buildSwipers = function(swiperid) { var mySwiper = new Swiper ('#swiper-container-' + swiperid, { // Optional parameters spaceBetween: 30 }); mySwiper.appendSlide('
'); $scope.swipers[swiperid] = mySwiper; } $scope.setPhotos = function() { $timeout(function() { $scope.offers.forEach(function(offer){ var swiper = $scope.swipers[offer.ID]; for (var i=0;i'); swiper.removeSlide(1); } else { swiper.appendSlide('
'); } } $scope.loadOfferHistory(offer); }); }, 100); } $scope.loadOfferHistory = function(offer) { $timeout(function(){ $http.get('https://housingimmo.be/api/v1/fr/' + gDomainId + '/offer/' + offer.ID + '/history',$scope.httpconfig).then(function (response){ if (typeof(response.data.errors) == 'undefined') { offer.history = response.data; for (var i=0;i