@ -0,0 +1,49 @@ |
|||
angular.module('app.savedEvents', ['pascalprecht.translate']) |
|||
|
|||
.controller('SavedEventsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading, $filter) { |
|||
|
|||
$scope.share = function(event){ |
|||
var message = event.description; |
|||
var subject = event.title; |
|||
var file= ['','']; |
|||
var link = "http://duckduckgo.com"; |
|||
$cordovaSocialSharing |
|||
.share(message, subject, file, link) // Share via native share sheet
|
|||
.then(function(result) { |
|||
// Success!
|
|||
}, function(err) { |
|||
// An error occured. Show a message to the user
|
|||
}); |
|||
}; |
|||
$scope.$on('$ionicView.enter', function(){//per executar-ho cada cop que es carrega el view
|
|||
$scope.savedEvents=[]; |
|||
if (localStorage.getItem("events_app_savedEvents")) { |
|||
$scope.savedEvents = JSON.parse(localStorage.getItem("events_app_savedEvents")); |
|||
console.log("savedEvents"); |
|||
console.log($scope.savedEvents); |
|||
} |
|||
$scope.events=$scope.savedEvents; |
|||
}); |
|||
$scope.saveEvent = function(event){ |
|||
$scope.savedEvents.push(event); |
|||
localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents)); |
|||
$ionicLoading.show({ template: 'Event saved', noBackdrop: true, duration: 1000 }); |
|||
}; |
|||
$scope.unsaveEvent = function(event){ |
|||
for(var i=0; i<$scope.savedEvents.length; i++) { |
|||
if ($scope.savedEvents[i]._id === event._id){ |
|||
$scope.savedEvents.splice(i, 1); |
|||
} |
|||
} |
|||
localStorage.setItem("events_app_savedEvents", JSON.stringify($scope.savedEvents)); |
|||
$ionicLoading.show({ template: 'Event unsaved', noBackdrop: true, duration: 1000 }); |
|||
}; |
|||
$scope.isEventSaved = function(event) { |
|||
for(var i=0; i<$scope.savedEvents.length; i++) { |
|||
if ($scope.savedEvents[i]._id === event._id){ |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
}; |
|||
}); |
@ -1,35 +1,37 @@ |
|||
<ion-view view-title="Events"> |
|||
<ion-content> |
|||
<ion-content class="c_blueGrey100"> |
|||
<ion-refresher pulling-text="{{'Pull_to_refresh' | translate}}..." on-refresh="doRefresh()"> |
|||
</ion-refresher> |
|||
|
|||
<!--<a class="item item-thumbnail-left" href="#/app/events/{{event._id}}" |
|||
ng-repeat="event in events"> |
|||
<img ng-src="{{event.img}}"> |
|||
<div class="badge item-note">{{event.user.username}}</div> |
|||
<h2>{{event.title}}</h2> |
|||
<p>{{event.description}}</p> |
|||
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p> |
|||
</a>--> |
|||
<div ng-repeat="event in events"> |
|||
|
|||
<div class="card" ng-repeat="event in events"> |
|||
<a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}"> |
|||
<img ng-src="{{event.user.img}}"> |
|||
<h2>{{event.user.username}}</h2> |
|||
<p>{{event.user.shortDescription}}</p> |
|||
</a> |
|||
<a ng-href="#/app/events/{{event._id}}" class="item item-image"> |
|||
|
|||
<img ng-src="{{event.img}}"> |
|||
<div style="text-align: left; padding: 20px;"> |
|||
<h2>{{event.title}}</h2> |
|||
<p>{{event.description}}</p> |
|||
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p> |
|||
</div> |
|||
</a> |
|||
<div class="item tabs tabs-icon-only"> |
|||
<a class="tab-item" ng-click="share(event)"> |
|||
<i class="icon ion-android-share-alt"></i> |
|||
</a> |
|||
<a class="tab-item"> |
|||
|
|||
<a class="item item-icon-left ct_indigo500" ng-click="share()"> |
|||
<i class="icon ion-android-share-alt"></i> Share |
|||
</a> |
|||
<div class="item"></div> |
|||
</a> |
|||
<a class="tab-item" ng-click="unsaveEvent(event)" |
|||
ng-show="isEventSaved(event)"> |
|||
<i class="icon ion-heart ctext_red600"></i> |
|||
</a> |
|||
<a class="tab-item" ng-click="saveEvent(event)" |
|||
ng-hide="isEventSaved(event)"> |
|||
<i class="icon ion-heart"></i> |
|||
</a> |
|||
</div> |
|||
</div> |
|||
</ion-content> |
|||
</ion-view> |
@ -0,0 +1,35 @@ |
|||
<ion-view view-title="Saved Events"> |
|||
<ion-content class="c_blueGrey100"> |
|||
<div class="card" ng-repeat="event in events"> |
|||
<a class="item item-avatar" ng-href="#/app/users/{{event.user._id}}"> |
|||
<img ng-src="{{event.user.img}}"> |
|||
<h2>{{event.user.username}}</h2> |
|||
<p>{{event.user.shortDescription}}</p> |
|||
</a> |
|||
<a ng-href="#/app/events/{{event._id}}" class="item item-image"> |
|||
<img ng-src="{{event.img}}"> |
|||
<div style="text-align: left; padding: 20px;"> |
|||
<h2>{{event.title}}</h2> |
|||
<p>{{event.description}}</p> |
|||
<p>{{event.date | date: 'HH:mm, dd/MM/yyyy'}}</p> |
|||
</div> |
|||
</a> |
|||
<div class="item tabs tabs-icon-only"> |
|||
<a class="tab-item" ng-click="share(event)"> |
|||
<i class="icon ion-android-share-alt"></i> |
|||
</a> |
|||
<a class="tab-item"> |
|||
|
|||
</a> |
|||
<a class="tab-item" ng-click="unsaveEvent(event)" |
|||
ng-show="isEventSaved(event)"> |
|||
<i class="icon ion-heart ctext_red600"></i> |
|||
</a> |
|||
<a class="tab-item" ng-click="saveEvent(event)" |
|||
ng-hide="isEventSaved(event)"> |
|||
<i class="icon ion-heart"></i> |
|||
</a> |
|||
</div> |
|||
</div> |
|||
</ion-content> |
|||
</ion-view> |