Instantly share code, notes, and snippets.
Forked from coolbung/albumphotos.html
Created
September 4, 2016 07:57
-
Star
(0)
0
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save sreedharbukya/964b5b710ac81a40c38371de9ea42098 to your computer and use it in GitHub Desktop.
Multiple Photo Upload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="overlay ng-scope overlay-show" id="albumphots_dialog" toggleable="" parent-active-class="overlay-in" active-class="overlay-show"> | |
<div class="navbar navbar-app navbar-absolute-top"> | |
<div class="btn-group pull-left pullLeftWidthAlbum"> | |
<div class="btn btn-navbar divOverflow" ng-hide="addPhotoDiv"> | |
<span ng-click="toggleAction('albumphots_dialog'); | |
title = 'albums'"> | |
<i class="fa fa-chevron-left"></i> | |
{{ title | uppercase }} | |
</span> | |
</div> | |
<div class="btn btn-navbar" ng-show="addPhotoDiv" ng-click="addPhotoDiv = false"> | |
<i class="fa fa-chevron-left"></i> {{'label.CANCEL'| translate }} | |
</div> | |
</div> | |
<div class="btn btn-navbar pull-right" ng-init="addPhotoDiv = false" ng-hide="addPhotoDiv || !isAlbumOwner" ng-click="addPhotoDiv = true; | |
newAlbumPhotos = []; | |
uploadAlbumImagesInprogress = false;"> | |
<!--<button class="btn"> {{'label.ADD_PHOTOS' | translate}} </button>--> | |
<i ng-show="isAlbumOwner" class="fa fa-plus iconshift"></i> | |
</div> | |
<div ng-click="albumPhotosView(title, albumId);" class="btn btn-navbar pull-right" ng-hide="addPhotoDiv"> | |
<i class="fa fa-rotate-right iconshift"></i> | |
</div> | |
<div class="btn-group pull-right" ng-show="addPhotoDiv"> | |
<button class="btn" ng-click="uploadAlbumImages();"> {{'label.UPLOAD'| translate }} </button> | |
</div> | |
</div> | |
<div class="overlay-inner"> | |
<div class="overlay-content"> | |
<div class="overlay-body"> | |
<div class="list-group"> | |
<div class="list-group-item" ng-model="flag" ng-init="flag = true" ng-hide="addPhotoDiv"> | |
<div class="row gallery"> | |
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 thumb album-img-responsive" ng-repeat="images in albumPhotos" ng-show="images.image_large"> | |
<div class="photos-grid divNoSelect"> | |
<img class="" ng-src="{{images.image_large}}" on-long-press="deletePhoto(title,albumId,images.id,isAlbumOwner)" ng-click="openAlbumPhotoZoom(images, albumPhotos, $index)"> | |
</div> | |
</div> | |
</div> | |
<list ng-if="flag" ng-show="photosLoadMore && !loader.loading"> | |
<button class="btn loadMore" ng-click="loadMore()">{{'label.LOADMORE'| translate}}</button> | |
</list> | |
<h5 class="text-center nodata" ng-if="albumPhotos.length == '0'" ng-hide="loader.loading"> | |
{{'label.NO_PHOTOS'| translate}} | |
</h5> | |
</div> | |
<!-- | |
<list ng-if="albumPhotos" ng-hide="addPhotoDiv || (albumPhotos.length%ESLimit.photos_pagination_limit) != 0 || loaderBtn || albumPhotos.length==0" ng-disabled="loader.loading" class="navbar navbar-app navbar-absolute-bottom"> | |
<center> | |
<button class="btn" ng-click="loadMore()">{{lloadmore}}</button> | |
</center> | |
</list> | |
--> | |
<div class="customise-settings" ng-if="addPhotoDiv"> | |
<div class=""> | |
<div class="border-bottom-red"> | |
<h4>{{'label.ADD_PHOTOS'| translate }}</h4> | |
</div> | |
<div class=""> | |
<label class="control-label"></label> | |
<div class="row text-center"> | |
<div class="col-xs-6"> | |
<button style="padding: 6px;" class="btn btn-primary btn-width-full" camera-avatar ng-model='album_avatar'><i class="fa fa-camera-retro"></i> {{'label.FROM_CAMERA'| translate }} </button> | |
</div> | |
<div class="col-xs-6"> | |
<button class="btn btn-primary btn-width-full" ng-click="multiImage();" ng-model='album_avatar'><i class="fa fa-file-image-o"></i> {{'label.FROM_GALERY'| translate }} </button> | |
</div> | |
</div> | |
</div> | |
<br/> | |
<!-- | |
<div class="row gallery"> | |
<div class="col-lg-3 col-md-4 col-xs-6 thumb" ng-repeat="images in newAlbumPhotos" ng-show="newAlbumPhotos"> | |
<img class="album-img-responsive" ng-src="{{images.path}}" ng-click="openZoom(images.path)" > | |
<div class="progress"> | |
<div class="progress-bar" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: {{images.progress}}"></div> | |
</div> | |
</div> | |
</div> | |
--> | |
<div class="row gallery"> | |
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-3 thumb album-img-responsive" ng-repeat="images in newAlbumPhotos" ng-show="newAlbumPhotos"> | |
<div class="photos-grid divNoSelect"> | |
<img class="album-image-grid" ng-src="{{images.path}}" ng-click="openZoom(images.path)" > | |
<div class="progress"> | |
<div class="progress-bar" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: {{images.progress}}"></div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var socialappCtrl = angular.module('socialapp.controllers', ['ngRoute', 'ngTouch', 'LocalStorageModule', 'lib-ui', 'ngSanitize']); | |
// EasySocial app controller function. This will be used across the app mostly | |
socialappCtrl.controller('easysocialCtrl', function ($scope, $route, $translate, $rootScope, $location, localStorageService, easysocialService, LoginService, action, checkConnection, $http, $sce, $anchorScroll, $filter) { | |
$scope.members = []; | |
$scope.newAlbumPhotos = []; | |
// Start of side-panel menu | |
//juniteservice is used | |
LoginService.getcomponentlist().then(function (data) { | |
/* format data - vishal*/ | |
$scope.curr_arr = new Array(); | |
$rootScope.marr = new Array(); | |
for (var i = 0; i < data.length; i++) { | |
$scope.curr_arr = ($scope.curr_arr.length > 0) ? $scope.curr_arr.concat(data[i].menu) : data[i].menu; | |
} | |
storeFilter($scope.curr_arr); | |
//end | |
$scope.componentData = data; | |
}, function (_error) { | |
$rootScope.showalert("error", _error.message); | |
}); | |
//Get Notification Details count to show | |
/*juniteService.getnotificationlist().then(function(data) { | |
$scope.componentData = data; | |
}, function(_error) { | |
$rootScope.showalert("error", _error.message); | |
});*/ | |
/*Dynamic limit set */ | |
$rootScope.setAllLimit(); | |
/*ES version amd limit access on template */ | |
$rootScope.ESVersion = easysocial_count.version; | |
$rootScope.ESLimit = easysocial_count; | |
$scope.getMenuData = $scope.componentData; | |
// End of menu : Discover API. | |
// Initializing the objects | |
$scope.comment = { | |
commentbox: "" | |
}; | |
$scope.share = { | |
sharebox: "" | |
}; | |
$scope.people = { | |
search: "" | |
}; | |
// Limit comes from languageconstant.js | |
localStorageService.set("limitIs", easysocial_count.stream_limit); | |
$scope.refreshBtn = !($location.path() == pathConstant.SOCIAL_FRIENDS_VIEW_PATH || $location.path() == pathConstant.SOCIAL_MOREDETAIL_VIEW_PATH); | |
// Switch based on page action | |
switch (action) { | |
case "newsfeed": | |
default: | |
if (checkConnection()) { | |
/* Newsfedd Filter Me, Photos .. */ | |
$scope.shareTitle = $translate.instant('label.SHARE'); | |
$scope.newsfeedFilter = localStorageService.get("newsfeedFilter"); | |
localStorageService.set("prevNewsfeedFilter", $scope.newsfeedFilter); | |
localStorageService.set("groupid", null); | |
localStorageService.set("eventid", null); | |
localStorageService.set("videoid", null); | |
//Menu slide active submenu using filter | |
if ($scope.newsfeedFilter == null) { | |
$rootScope.selected = 1; | |
} else { | |
var filter = ["null", "me", "everyone", "following", "sticky", "photos", "me"]; | |
$rootScope.selected = filter.indexOf($scope.newsfeedFilter) + 1; | |
} | |
if (localStorageService.get("auth_key")) { | |
/* Image url set for full screen .. */ | |
$scope.getUrl = function () { | |
//$scope.zoomImageUrl = localStorageService.get("imgUrlZoom"); | |
} | |
$scope.loaderBtn = true; | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", "0"); | |
if (localStorageService.get("username") == null || localStorageService.get("username") == undefined) { | |
/* Get login profile details */ | |
easysocialService.profile().then(function (profileData) { | |
//if (profileData.code == 200) { | |
if (profileData) { | |
localStorageService.set("username", profileData.username); | |
//localStorageService.set("userphoto", profileData.image.image_medium ); | |
localStorageService.set("currentuname", profileData.username); | |
//$rootScope.hideloader(); | |
} else { | |
return false; | |
} | |
}); | |
} | |
/* Get Newsfeed Stream */ | |
easysocialService.newsfeed().then(function (data) { | |
// To load more newsfeed streams | |
if (!data.code) { | |
$scope.streams = data; | |
$rootScope.hideloader(); | |
} | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.stream_limit); | |
easysocialService.newsfeed().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.stream_limit); | |
$rootScope.hideloader(); | |
} else { | |
$scope.streams = $scope.streams.concat(data); | |
if (callback) { | |
callback(); | |
} | |
$rootScope.hideloader(); | |
} | |
} | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
case "viewprofile": | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
localStorageService.set("clusterType", ""); | |
localStorageService.set("albumEventType", "user"); | |
if (localStorageService.get("auth_key")) { | |
$scope.loaderBtn = true; | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", "0"); | |
localStorageService.set("newsfeedFilter", "me"); | |
localStorageService.set("groupid", null); | |
localStorageService.set("eventid", null); | |
localStorageService.set("videoid", null); | |
/* Get Profile Details of any user */ | |
easysocialService.profile().then(function (profileData) { | |
$scope.profileData = profileData; | |
localStorageService.set("moreDetail", JSON.stringify(profileData)); | |
localStorageService.set("currentuname", profileData.username); | |
$rootScope.isAlbumOwner = profileData.isself; | |
$rootScope.title = profileData.username; | |
$scope.shareTitle = $translate.instant('label.WRITEON') + " " + profileData.username + $translate.instant('label.WALL'); | |
}); | |
/* Get Newsfeed stream of that Profile */ | |
easysocialService.newsfeed().then(function (data) { | |
if (!data.code) | |
$scope.streams = data; | |
// To load more profile streams | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.stream_limit); | |
easysocialService.newsfeed().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.stream_limit); | |
} else { | |
$scope.streams = $scope.streams.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
$rootScope.hideloader(); | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
// Method to send follow user request | |
$scope.followRequest = function (element) { | |
var user_id = element.profileData.id; | |
if (element.profileData.isfollower) { | |
navigator.notification.confirm($translate.instant('message.UNFOLLOW_USER'), function (result) { | |
if (result == 2) { | |
element.profileData.isfollower = !element.profileData.isfollower; | |
easysocialService.follow('0').then(function (data) { | |
if (!data.code) { | |
if (data.success == "1") { | |
$rootScope.showalert("success", data.message); | |
} else { | |
$rootScope.showalert("error", data.message); | |
} | |
} | |
}); | |
return false; | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
return false; | |
} else { | |
element.profileData.isfollower = !element.profileData.isfollower; | |
easysocialService.follow('1').then(function (data) { | |
if (!data.code) { | |
if (data.success == "1") { | |
$rootScope.showalert("success", data.message); | |
} else { | |
$rootScope.showalert("error", data.message); | |
} | |
} | |
}); | |
} | |
}; | |
// For navigating to user's more detail page | |
$scope.gotoMoreDetail = function () { | |
$rootScope.toggle('moredetail_dialog', 'on'); | |
localStorageService.set("toggle", "moredetail_dialog"); | |
}; | |
// Added by pratiksha For navigating to new message view page | |
$scope.gotoMessage = function (pid, username) { | |
$rootScope.tag_name = username; | |
localStorageService.set("recipients", ""); | |
localStorageService.set("recipientIds", ""); | |
}; | |
//~ // Method to send message | |
$scope.sendMessage = function (pid, username) { | |
$scope.message.recipient = username; | |
$scope.message.recipientIds = []; | |
$scope.message.recipientIds.push(pid); | |
if ($scope.message.recipientIds.length == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_RECIPIENT_NAME')); | |
} else if (!$scope.message.content) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_MESSAGE')); | |
} else if ($scope.message.recipientIds && $scope.message.content) { | |
$rootScope.showloader(); | |
localStorageService.set("conversationId", "0"); | |
localStorageService.set("recipientIds", $scope.message.recipientIds); | |
easysocialService.postreply($scope.message.content).then(function (data) { | |
//if (!data.code){ | |
if (data.status) { | |
$rootScope.showalert("success", data.message); | |
$location.path(pathConstant.SOCIAL_CONVERSATION_VIEW_PATH); | |
$scope.showConversationlist(); | |
} else { | |
$rootScope.showalert("warning", data.message); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
//Block user | |
$scope.blockUser = function(id,block) | |
{ | |
$scope.uid = id; | |
$scope.block = block; | |
if($scope.block==1) | |
{ | |
$scope.msg = $translate.instant('message.WANT_BLOCK_USER'); | |
}else | |
{ $scope.msg = $translate.instant('message.WANT_UNBLOCK_USER'); | |
} | |
navigator.notification.confirm($scope.msg, function (result) { | |
if (result == 2) { | |
easysocialService.blockuser($scope.uid,$scope.block).then(function (data) { | |
if (!data.code) | |
{ | |
if (data.success == "1") | |
{ | |
$rootScope.showalert("success", data.message); | |
$scope.viewUserprofile(); | |
} else { | |
$rootScope.showalert("error", data.message); | |
$scope.viewUserprofile(); | |
} | |
} | |
}); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
}; | |
} | |
break; | |
case "friends": | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
// Method to load friends list | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
$rootScope.friends = ""; | |
$scope.loaderBtn = true; | |
$scope.loginUserId = localStorageService.get("userid"); | |
var currentuid = localStorageService.get("currentuid"); | |
var userid = localStorageService.get("userid"); | |
if (currentuid != userid) { | |
$scope.friendfilterdiv = true; | |
} else { | |
$scope.friendfilterdiv = false; | |
} | |
//Initializing limit | |
localStorageService.set("startLimit", "0"); | |
localStorageService.set("limitIs", easysocial_count.FRIENDS_LIMIT); | |
//Get value of frien list filter. | |
$rootScope.friendFilter = localStorageService.get("friendlistFilter"); | |
//For the tabPos class value set (Top filter position set). | |
if ($rootScope.friendFilter == 'search' || $rootScope.friendFilter == 'all' || $rootScope.friendFilter == 'suggest') { | |
$rootScope.tabPos = "positionInitial"; | |
} | |
if ($rootScope.friendFilter == 'pending' || $rootScope.friendFilter == 'request' || $rootScope.friendFilter == 'invites') { | |
$rootScope.tabPos = "positionRight"; | |
} | |
//Friend view title set with profile name set. | |
if (localStorageService.get("friendlist")) { | |
$rootScope.title = $translate.instant('titleConstant.SOCIAL_FRIEND_LAST_WITHOUTS'); | |
} else { | |
if (localStorageService.get("currentuname")) | |
$rootScope.title = localStorageService.get("currentuname") + $translate.instant('titleConstant.SOCIAL_FRIEND_LAST'); | |
} | |
//Get Friend filter list | |
if ($rootScope.friendFilter != 'search') { | |
easysocialService.friends().then(function (data) { | |
if (!data.code) { | |
$rootScope.friends = data.data; | |
if (data.data_status) { | |
//Load more as per the total count | |
$rootScope.friendsLoadMore = parseInt(data.status[$rootScope.friendFilter]) - (parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.FRIENDS_LIMIT)); | |
$rootScope.friendsLoadMore = $rootScope.friendsLoadMore <= 0 ? false : true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
} | |
//Active tab on friend list filter | |
var frequest = "#f" + localStorageService.get("friendlistFilter"); | |
$(frequest).addClass("active"); | |
$rootScope.hideloader(); | |
// To load more friends records | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.FRIENDS_LIMIT); | |
easysocialService.friends().then(function (data) { | |
if (!data.code) { | |
if (data.data_status) { | |
//Load more as per the total count | |
$rootScope.friendsLoadMore = parseInt(data.status[$rootScope.friendFilter]) - (parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.FRIENDS_LIMIT)); | |
$rootScope.friendsLoadMore = $rootScope.friendsLoadMore <= 0 ? false : true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
if (data.data.length == 0 || !data.data_status) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.FRIENDS_LIMIT); | |
} else { | |
$rootScope.friends = $rootScope.friends.concat(data.data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
} else { | |
//Active class for search | |
$('#fsearch').addClass("active"); | |
$rootScope.friendsLoadMore = false; | |
//For reload page the temp store the value of search | |
$scope.people.search = $rootScope.searchPeopleTemp; | |
//$rootScope.search_people($scope.people.search); | |
var searchName = ""; | |
if ($scope.people.search) | |
searchName = $scope.people.search; | |
else | |
searchName = $scope.people.search; | |
if (searchName) { | |
$rootScope.friends = ""; | |
$rootScope.showloader(); | |
easysocialService.search_people(searchName).then(function (data) { | |
if (!data.code) { | |
if (data.user == 0) { | |
$rootScope.friends = '0'; | |
} else { | |
$rootScope.friends = data.user; | |
if (data.data_status) { | |
//Load more as per the total count | |
if ($rootScope.friends.length % easysocial_count.FRIENDS_LIMIT == 0 && $rootScope.friends.length > 0) { | |
$rootScope.friendsLoadMore = true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
//$rootScope.friendsLoadMore = parseInt(parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.FRIENDS_LIMIT)); | |
//$rootScope.friendsLoadMore = $rootScope.friendsLoadMore <= 0 ? false : true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
} | |
} | |
$rootScope.title = $translate.instant('label.SEARCH_RESULT'); | |
$rootScope.hideloader(); | |
}); | |
} | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
// $rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.FRIENDS_LIMIT); | |
easysocialService.search_people(searchName).then(function (data) { | |
if (!data.code) { | |
if (data.user == 0) { | |
$rootScope.friends = '0'; | |
} else { | |
$rootScope.friends = $rootScope.friends.concat(data.user); | |
if (data.data_status) { | |
//Load more as per the total count | |
if ($rootScope.friends.length % easysocial_count.FRIENDS_LIMIT == 0 && $rootScope.friends.length > 0) { | |
$rootScope.friendsLoadMore = true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
if (callback) { | |
callback(); | |
} | |
} | |
//$rootScope.friendsLoadMore = parseInt(parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.FRIENDS_LIMIT)); | |
//$rootScope.friendsLoadMore = $rootScope.friendsLoadMore <= 0 ? false : true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
} | |
} | |
$rootScope.title = $translate.instant('label.SEARCH_RESULT'); | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
} | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
case "followers": | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
$rootScope.showloader(); | |
$rootScope.followers = ""; | |
$scope.loaderBtn = true; | |
easysocialService.followers().then(function (data) { | |
if (!data.code) { | |
$rootScope.followers = data.data; | |
} | |
if (localStorageService.get("currentuname")) | |
$rootScope.title = localStorageService.get("currentuname") + $translate.instant('label.SOCIAL_FOLLOWERS'); | |
$rootScope.hideloader(); | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
case "grouplist": | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
$scope.saveGroup = true; | |
$scope.model = { | |
name: 'World' | |
}; | |
$scope.name = "Felipe"; | |
// Method to load groups list | |
$scope.showGrouplist = function () { | |
localStorageService.set("startLimit", "0"); | |
localStorageService.set("limitIs", easysocial_count.GROUPS_LIMIT); | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
$scope.groups = ""; | |
$scope.loaderBtn = true; | |
var currentuid = localStorageService.get("currentuid"); | |
var userid = localStorageService.get("userid"); | |
if (currentuid != userid) { | |
$scope.groupfilterdiv = true; | |
} else { | |
$scope.groupfilterdiv = false; | |
} | |
//Get value of group list filter. | |
$rootScope.groupFilter = localStorageService.get("grouplistFilter"); | |
//For the tabPos class value set (Top filter position set). | |
if ($rootScope.groupFilter == 'search' || $rootScope.groupFilter == 'all' || $rootScope.groupFilter == 'featured') { | |
$rootScope.tabPos = "positionInitial"; | |
} | |
if ($rootScope.groupFilter == 'mygroups' || $rootScope.groupFilter == 'invited') { | |
$rootScope.tabPos = "positionRight"; | |
} | |
easysocialService.grouplist().then(function (data) { | |
if (!data.code) { | |
if (data == "false" || data.length == 0) { | |
} else { | |
$scope.groups = data; | |
$scope.group_message = data.message; | |
} | |
} | |
var frequest = "#g" + localStorageService.get("grouplistFilter"); | |
$(frequest).addClass("active"); | |
$rootScope.hideloader(); | |
// To load more groups | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.GROUPS_LIMIT); | |
easysocialService.grouplist().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0 || data.length === undefined) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.GROUPS_LIMIT); | |
} else { | |
$scope.groups = $scope.groups.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
}; | |
// For navigating to create new group page | |
$scope.gotoNewGroup = function () { | |
$rootScope.toggle('newgroup_dialog', 'on'); | |
localStorageService.set("toggle", "newgroup_dialog"); | |
localStorageService.set("group_categoryid", ""); | |
localStorageService.set("avatarImagepath", ""); | |
localStorageService.set("coverImagepath", ""); | |
$scope.selectcategory = {}; | |
$scope.group_title = ""; | |
$scope.group_permalink = ""; | |
$scope.group_description = ""; | |
$scope.group_website = ""; | |
$scope.group_type = ""; | |
$scope.albums = true; | |
$scope.announcements = true; | |
$scope.discussions = true; | |
var str = cordova.file.applicationDirectory; | |
var res = str.substring(7, str.length); | |
$scope.group_avatar = res + "www/components/easysocial/css/custom/img/nouser.png"; | |
}; | |
// LeaveThisGroup | |
$scope.leaveThisGroup = function (group) { | |
navigator.notification.confirm($translate.instant('message.DELETE_GROUP'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.leaveThisGroup(group).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
$location.path(pathConstant.SOCIAL_GROUPLIST_VIEW_PATH); | |
$scope.showGrouplist(); | |
} | |
$rootScope.hideloader(); | |
}); | |
$rootScope.showloader(); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
}; | |
/* Group categories load */ | |
var getstoredparentlist; | |
/* Checking at localstorage group categories present or not | |
* If present then not to required service to call */ | |
if (localStorageService.get("groupcatlist") == null || localStorageService.get("groupcatlist") == '' || localStorageService.get("groupcatlist") == undefined) { | |
easysocialService.getcategories().then(function (data) { | |
var catdataArray = []; | |
/* Group categorie array created and assign to model */ | |
angular.forEach(data.data, function (value, key) { | |
var category = value | |
catdataArray.push({ | |
"value": category.categoryid, | |
"title": category.title | |
}); | |
}); | |
localStorageService.set('groupcatlist', JSON.stringify(catdataArray)); | |
$scope.categoryTemplate = catdataArray; | |
}); | |
} else { | |
getstoredparentlist = localStorageService.get("groupcatlist"); | |
var catdataArray = []; | |
for (var key in getstoredparentlist) { | |
catdataArray.push({ | |
'title': getstoredparentlist[key].title, | |
'value': getstoredparentlist[key].value | |
}) | |
} | |
$scope.categoryTemplate = catdataArray; | |
} | |
// For creating new group with validation | |
$scope.saveGroupData = function () { | |
$scope.changedValuecat(); | |
//if(!localStorageService.get("group_categoryid")){ | |
if (localStorageService.get("group_categoryid") == null) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_GROUP_CATEGORY')); | |
} else if (!$scope.group_title) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_GROUP_TITLE')); | |
} else if (!$scope.group_permalink) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_GROUP_PERMALINK')); | |
} else if (!$scope.group_description) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_GROUP_DESCRIPTION')); | |
} | |
// see issue feedback #63203 | |
// else if (!$scope.newblogform.group_website.$valid) { | |
// $rootScope.showalert("warning", $translate.instant('message.REQUIRE_SITE_URL_GROUP')); | |
// } | |
else if (!$scope.group_type) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_GROUP_TYPE')); | |
} else { | |
$rootScope.showloader(); | |
$scope.saveGroup = false; | |
/* In api required in flag type | |
* As type check true false the flag set*/ | |
var discussionsflag = 1, | |
announcementsflag = 1, | |
albumsflag = 1; | |
if ($scope.albums == true) { | |
albumsflag = 1; | |
} else { | |
albumsflag = 0; | |
} | |
if ($scope.announcements == true) { | |
announcementsflag = 1; | |
} else { | |
announcementsflag = 0; | |
} | |
if ($scope.discussions == true) { | |
discussionsflag = 1; | |
} else { | |
discussionsflag = 0; | |
} | |
/* If validation done then | |
* One group object create and pass to the create group service.*/ | |
$scope.groupdata = { | |
category: $scope.selectcategory.value, | |
title: $scope.group_title, | |
permalink: $scope.group_permalink, | |
description: $scope.group_description, | |
type: $scope.group_type, | |
website: $scope.group_website, | |
albums: albumsflag, //$scope.albums, | |
announcements: announcementsflag, //$scope.announcements, | |
discussions: discussionsflag, // $scope.discussions, | |
avatar: localStorageService.get("avatarImagepath"), | |
cover: localStorageService.get("coverImagepath") | |
}; | |
} | |
}; | |
/* On change of group category the id set*/ | |
$scope.changedValuecat = function (cat) { | |
if (cat != null) { | |
localStorageService.set('group_category', cat); | |
localStorageService.set('group_categoryid', cat.value); | |
} | |
}; | |
// For navigating to group detail | |
$scope.viewGroupDetail = function (id, isowner) { | |
if (id) { | |
localStorageService.set("groupid", id); | |
} | |
$location.path(pathConstant.SOCIAL_GROUPDETAIL_VIEW_PATH); | |
}; | |
$scope.showGrouplist(); | |
} | |
break; | |
case "groupdetail": | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
localStorageService.set("clusterType", "group"); | |
localStorageService.set("eventid", null); | |
$scope.loaderBtn = true; | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", "0"); | |
//localStorageService.set("newsfeedFilter", "me"); | |
/* Group profile Data */ | |
easysocialService.group().then(function (data) { | |
data.data.forEach(function(entry) { | |
var temp = JSON.parse(entry.params); | |
$rootScope.allowNewDiscussion = temp.discussions; | |
$rootScope.ownerFlag = entry.isowner; | |
$rootScope.memberFlag = entry.ismember; | |
}); | |
localStorageService.set("moreGroupDetail", data); | |
$scope.profileData = data.data[0]; | |
var params = JSON.parse(data.data[0].params); | |
//API params node converted into object | |
$scope.profileData = angular.extend(params, data.data[0]); | |
$rootScope.title = data.data[0].title; | |
$scope.shareTitle = $translate.instant('label.WRITEON') + " " + $rootScope.title + $translate.instant('label.GROUPWALL'); | |
}); | |
/* Group newsfeed shown on group profile */ | |
easysocialService.newsfeed().then(function (data) { | |
if (!data.code) | |
$scope.streams = data; | |
// To load more group streams | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.stream_limit); | |
easysocialService.newsfeed().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.stream_limit); | |
} else { | |
$scope.streams = $scope.streams.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
$rootScope.hideloader(); | |
}); | |
//go to group album | |
$scope.groupAlbum = function () { | |
localStorageService.set("albumEventType", "group"); | |
} | |
// leaveGroup from group detail | |
$scope.leaveGroup = function () { | |
navigator.notification.confirm($translate.instant('message.DELETE_GROUP'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.leaveGroup().then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
$location.path(pathConstant.SOCIAL_GROUPLIST_VIEW_PATH); | |
$scope.showGrouplist(); | |
} | |
$rootScope.hideloader(); | |
}); | |
$rootScope.showloader(); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
}; | |
/* Delete Group */ | |
$scope.deleteGroup = function (groupid) { | |
navigator.notification.confirm($translate.instant('message.DELETE_GROUP'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.deletegroup(groupid).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
$location.path(pathConstant.SOCIAL_GROUPLIST_VIEW_PATH); | |
$scope.showGrouplist(); | |
} | |
$rootScope.hideloader(); | |
}); | |
$rootScope.showloader(); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
}; | |
//Join group function | |
$scope.joinGroup = function (groupid) { | |
$rootScope.showloader(); | |
easysocialService.joinGroup(groupid).then(function (data) { | |
if (!data.code) { | |
if (data.success == "1") { | |
$rootScope.showalert("success", data.message); | |
} else { | |
$rootScope.showalert("error", data.message); | |
} | |
$location.path(pathConstant.SOCIAL_GROUPLIST_VIEW_PATH); | |
$scope.showGrouplist(); | |
} | |
$rootScope.hideloader(); | |
}); | |
}; | |
} else { | |
$rootScope.logoutApp(); | |
} | |
// For navigating to group's more detail page | |
$scope.gotoMoreGroupDetail = function () { | |
$rootScope.toggle('moregroupdetail_dialog', 'on'); | |
localStorageService.set("toggle", "moregroupdetail_dialog"); | |
}; | |
} | |
break; | |
case "groupmembers": | |
/* Group members list shown */ | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
$rootScope.showloader(); | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
$scope.groupid = localStorageService.get("groupid"); | |
$scope.groupowner = localStorageService.get("groupowner"); | |
$scope.filt = ''; | |
$scope.type = 'group'; | |
$scope.loginUserId = localStorageService.get("currentuid"); | |
localStorageService.set("startLimit",0); | |
//Getting list of Group memeber | |
easysocialService.groupmembers($scope.filt, $scope.groupid, $scope.type).then(function (data) { | |
if (!data.code) { | |
$rootScope.friends = data; | |
} | |
if (name) | |
$rootScope.title = name + $translate.instant('titleConstant.SOCIAL_GROUP_MEMBERS_LAST'); | |
$rootScope.hideloader(); | |
// To load more friends records | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.FRIENDS_LIMIT); | |
easysocialService.groupmembers($scope.filt, $scope.groupid, $scope.type).then(function (data) { | |
if (!data.code) { | |
if (data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.FRIENDS_LIMIT); | |
} else { | |
$scope.friends = $scope.friends.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
$scope.deletegroupMember = function (index, profileData) { | |
navigator.notification.confirm($translate.instant('message.DELETE_GROUPMEMBER'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.deletegroupMember(profileData).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
easysocialService.groupmembers($scope.filt, $scope.groupid, $scope.type).then(function (data) { | |
if (!data.code) { | |
$rootScope.friends = data; | |
} | |
}); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
} | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
} | |
break; | |
case "eventmembers": | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
localStorageService.set("startLimit",0); | |
$rootScope.showloader(); | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
$scope.guesteventid = localStorageService.get("eventid"); | |
if (localStorageService.get("eventguestFilter") == null) { | |
localStorageService.set("eventguestFilter", 'going'); | |
} | |
$scope.eowner = localStorageService.get("eventowner"); | |
$scope.currentuid = localStorageService.get("currentuid"); | |
$scope.owner_log = false; | |
$rootScope.groupIsOwner = false; | |
if($scope.eowner == $scope.currentuid) | |
{ | |
$rootScope.groupIsOwner = $scope.currentuid; | |
$rootScope.eventid = localStorageService.get("eventid"); | |
} | |
$scope.filt = localStorageService.get("eventguestFilter"); | |
$scope.type = 'event'; | |
//Getting list of Event memeber | |
easysocialService.groupmembers($scope.filt, $scope.guesteventid, $scope.type).then(function (data) { | |
if (!data.code) { | |
$rootScope.friends = data; | |
} | |
var frequest = "#f" + localStorageService.get("eventguestFilter"); | |
$(frequest).addClass("active"); | |
$rootScope.hideloader(); | |
// To load more friends records | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.FRIENDS_LIMIT); | |
easysocialService.groupmembers($scope.filt, $scope.guesteventid, $scope.type).then(function (data) { | |
if (!data.code) { | |
if (data.length == 0 || data.status == false) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.FRIENDS_LIMIT); | |
} else { | |
$scope.friends = $scope.friends.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
} | |
break; | |
case "discussions": | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
localStorageService.set("startLimit", "0"); | |
// Method to load discussions | |
$scope.showDiscussionlist = function () { | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
$scope.groups = ""; | |
$scope.loaderBtn = true; | |
easysocialService.discussions().then(function (data) { | |
if (!data.code && data.data.length != 0) | |
$scope.groups = data.data; | |
/* Checking which discussion filter is active */ | |
var frequest = "#d" + localStorageService.get("discussionFilter"); | |
$(frequest).addClass("active"); | |
$rootScope.hideloader(); | |
// To load more group discussions | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.GROUPS_LIMIT); | |
easysocialService.discussions().then(function (data) { | |
if (!data.code) { | |
if (data.data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.GROUPS_LIMIT); | |
} else { | |
$scope.groups = $scope.groups.concat(data.data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
}; | |
$scope.whatClassIsIt = function (someValue) { | |
if (someValue == "Private") | |
return "fa fa-lock"; | |
else if (someValue == "Public") | |
return "fa fa-calendar"; | |
else | |
return "fa fa-calendar"; | |
} | |
// For navigating to create new discussion page | |
$scope.gotoNewDiscussion = function () { | |
$rootScope.toggle('newdiscussion_dialog', 'on'); | |
localStorageService.set("toggle", "newdiscussion_dialog"); | |
$scope.discussion = { | |
title: "", | |
description: "" | |
}; | |
}; | |
// For creating new group discussion | |
$scope.createNewDiscussion = function () { | |
if ($scope.discussion.title == "") { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_DISCUSSION_TITLE')); | |
} else if ($scope.discussion.description == "") { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_DISCUSSION_DESCRIPTION')); | |
} else if ($scope.discussion.title && $scope.discussion.description) { | |
$rootScope.showloader(); | |
easysocialService.creatediscussion($scope.discussion.title, $scope.discussion.description).then(function (data) { | |
//if(data.status) | |
//$rootScope.showalert(message.DISCUSSION_CREATED); | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
$scope.toggleAction('newdiscussion_dialog'); | |
$rootScope.hideloader(); | |
$scope.refresh(); | |
} | |
}); | |
} | |
}; | |
// For navigating to group discussion replies page | |
$scope.gotoRepliesView = function (element, className, done) { | |
localStorageService.set("discussionId", element.discussion.id); | |
//$rootScope.toggle('replies_dialog', 'on'); | |
//localStorageService.set("toggle", "replies_dialog"); | |
$rootScope.discussionreply = element.discussion; | |
$scope.replies = ""; | |
$scope.myreply.reply = ""; | |
$scope.loaderBtn = true; | |
$rootScope.showloader(); | |
$location.path(pathConstant.SOCIAL_DISCUSSIONS_REPLY_VIEW_PATH); | |
}; | |
$scope.showDiscussionlist(); | |
} | |
break; | |
case "discussionsreply": | |
/* Discussion reply case */ | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
localStorageService.set("startLimit", "0"); | |
$rootScope.showloader(); | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
/* Get Discussion replies */ | |
easysocialService.getreplies().then(function (data) { | |
if (!data.code) { | |
if(data.data.length !=0) | |
$scope.replies = data.data; | |
if(data.discussion.length !=0) | |
$scope.discussion = data.discussion[0]; | |
} | |
$rootScope.hideloader(); | |
// To load more discussion replies | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.GROUPS_LIMIT); | |
easysocialService.getreplies().then(function (data) { | |
if (!data.code) { | |
if (data.data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.GROUPS_LIMIT); | |
} else { | |
$scope.replies = $scope.replies.concat(data.data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
}); | |
$scope.postMyReply = function () { | |
if ($scope.myreply.reply) { | |
easysocialService.postdiscussionreply($scope.myreply.reply).then(function (data) { | |
if (!data.code) { | |
//$rootScope.showalert(message.REPLY_SENT_SUCCESS); | |
$rootScope.showalert("success", data.message); | |
$scope.replybox = !$scope.replybox; | |
$route.reload(); | |
} | |
$rootScope.hideloader(); | |
}); | |
} else { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_REPLY')); | |
} | |
} | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
} | |
break; | |
case "eventlist": | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
//Initialize limit | |
localStorageService.set("startLimit", "0"); | |
localStorageService.set("limitIs", easysocial_count.event_limit); | |
//Platform set for location map view | |
$scope.devicePlatform = device.platform; | |
//Get event list case | |
easysocialService.eventslist().then(function (data) { | |
if (!data.code) { | |
$scope.events = data; | |
} | |
$rootScope.hideloader(); | |
var eventlistFilter = localStorageService.get("eventlistFilter"); | |
var frequest = "#efilter" | |
if (eventlistFilter == 'all' || eventlistFilter == 'featured' || | |
eventlistFilter == 'mine' || eventlistFilter == 'invited') { | |
frequest = "#e" + localStorageService.get("eventlistFilter"); | |
} | |
$(frequest).addClass("active"); | |
$scope.loaderBtn = true; | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.event_limit); | |
if ($scope.loaderBtn) { | |
easysocialService.eventslist().then(function (data) { | |
if (!data.code) { | |
if (data.status == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.event_limit); | |
$rootScope.hideloader(); | |
} else { | |
$scope.events = $scope.events.concat(data); | |
if (callback) { | |
callback(); | |
} | |
$rootScope.hideloader(); | |
} | |
} | |
}); | |
} else { | |
$rootScope.hideloader(); | |
} | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
// $scope.loadMore = function() { | |
// if (checkConnection()) { | |
// $rootScope.showloader(); | |
// localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.event_limit); | |
// easysocialService.eventslist().then(function(data) { | |
// if (!data.code) { | |
// $scope.events = $scope.events.concat(data); | |
// } | |
// $rootScope.hideloader(); | |
// }); | |
// } | |
// }; | |
}); | |
//Get Event categories list and set to local storage | |
if (localStorageService.get("eventcatlist") == null || localStorageService.get("eventcatlist") == '' || localStorageService.get("eventcatlist") == undefined) { | |
easysocialService.geteventcategories().then(function (data) { | |
var catdataArray = []; | |
/* Group categorie array created and assign to model */ | |
angular.forEach(data, function (value, key) { | |
var category = value | |
catdataArray.push({ | |
"value": category.id, | |
"title": category.title | |
}); | |
}); | |
localStorageService.set('eventcatlist', JSON.stringify(catdataArray)); | |
$scope.eventCategory = localStorageService.get('eventcatlist'); | |
}); | |
} else { | |
$scope.eventCategory = localStorageService.get('eventcatlist'); | |
} | |
//Crate event repeat object | |
$scope.statusTemplate = [{ | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_DAILY'), | |
value: 'daily' | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_MONTHLY'), | |
value: 'monthly' | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_YEARLY'), | |
value: 'yearly' | |
}]; | |
//Event filter function. | |
$scope.openFilter = function () { | |
$rootScope.toggle('eventfilter_dialog', 'on'); | |
localStorageService.set("toggle", "eventfilter_dialog"); | |
//$scope.todayDate = new Date(); | |
var date = new Date(); | |
$scope.todayDate = $filter('date')(date, 'yyyy-MM-dd'); | |
$scope.year = date.getFullYear(); | |
$scope.month = $filter('date')(date, 'yyyy-MM'); | |
date.setDate(date.getDate() + 1); | |
$scope.tomorrow = $filter('date')(date, 'yyyy-MM-dd'); | |
date = new Date(); | |
date.setDate(date.getDate() + 7); | |
$scope.week1 = $filter('date')(date, 'yyyy-MM-dd'); | |
date = new Date(); | |
date.setDate(date.getDate() + 14); | |
$scope.week2 = $filter('date')(date, 'yyyy-MM-dd'); | |
} | |
//Set event filter. | |
$scope.setEventFilter = function (type, date, startDate, endDate, startBefore, cDate, categoryId) { | |
localStorageService.set("eventlistFilter", type); | |
localStorageService.set("date", date); | |
localStorageService.set("startDate", startDate); | |
localStorageService.set("endDate", endDate); | |
localStorageService.set("startBefore", startBefore); | |
localStorageService.set("cdate", $filter('date')(cDate, 'yyyy-MM-dd')); | |
localStorageService.set("categoryid", categoryId); | |
$scope.toggleAction('filter_dialog'); | |
$route.reload(); | |
} | |
//Open the create event overlay | |
$scope.gotoNewEvent = function () { | |
$rootScope.toggle('newevent_dialog', 'on'); | |
localStorageService.set("toggle", "newevent_dialog"); | |
$scope.isLocationMap = false; | |
var date = new Date(); | |
$scope.todayDate = $filter('date')(date, 'yyyy-MM-dd'); | |
// $scope.endRepeatD = $filter('date')(date, '2020-12-30'); | |
//Initialize the event data for create event | |
$scope.eventData = { | |
title: '', | |
eventCategory: null, | |
permalink: '', | |
startDate: new Date(), | |
startTime: new Date(date.getFullYear(), date.getMonth(), date.getDay(), date.getHours(), date.getMinutes(), 0), | |
endDate: null, | |
endTime: null, | |
eventAllDay: false, | |
repeat: null, | |
repeatDaily: null, | |
endRepeat: null, | |
description: '', | |
eventType: 1, | |
website: '', | |
maybeState: true, | |
goingState: true, | |
guestLimit: 0, | |
albums: true, | |
announcements: true, | |
discussions: true, | |
scheduleDate: [] | |
}; | |
localStorageService.set("address", null); | |
$scope.mapInitialization(); | |
}; | |
//Initialize the map | |
$scope.mapInitialization = function () { | |
var place = new google.maps.LatLng(localStorageService.get("lat"), | |
localStorageService.get("long")); | |
$scope.eventData.emapForm = new google.maps.Map(document.getElementById('mapCanvas'), { | |
center: place, | |
zoom: 15, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}); | |
$scope.eventData.emarker = new google.maps.Marker({ | |
position: place, | |
map: $scope.eventData.emapForm, | |
draggable: true | |
//icon: $rootScope.iconMarker | |
}); | |
var mapForm = $scope.eventData.emapForm; | |
//markers.push(marker); | |
var centerControlDiv = document.createElement('div'); | |
var centerControl = new CenterControl(centerControlDiv, $scope.eventData.emapForm); | |
$scope.eventData.emapForm.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(centerControlDiv); | |
function CenterControl(controlDiv, mapForm) { | |
// Set CSS for the control border | |
var controlUI = document.createElement('div'); | |
controlUI.style.backgroundColor = '#fff'; | |
controlUI.style.border = '2px solid #fff'; | |
controlUI.style.borderRadius = '3px'; | |
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)'; | |
controlUI.style.cursor = 'pointer'; | |
controlUI.style.marginBottom = '22px'; | |
controlUI.style.textAlign = 'center'; | |
controlUI.title = 'Click to recenter the map'; | |
controlDiv.appendChild(controlUI); | |
// Set CSS for the control interior | |
var controlText = document.createElement('div'); | |
controlText.style.color = 'rgb(25,25,25)'; | |
controlText.style.fontFamily = 'Roboto,Arial,sans-serif'; | |
controlText.style.fontSize = '16px'; | |
controlText.style.lineHeight = '38px'; | |
controlText.style.height = '38px'; | |
controlText.style.paddingLeft = '5px'; | |
controlText.style.paddingRight = '5px'; | |
controlText.innerHTML = '<i style="" class="fa fa-street-view fa-lg streetColor fa-lg-set"></i>'; | |
controlUI.appendChild(controlText); | |
// Setup the click event listeners: simply set the map to place | |
google.maps.event.addDomListener(controlUI, 'click', function () { | |
marker.setPosition(place); | |
$scope.eventData.emapForm.setCenter(place); | |
}); | |
} | |
// Add dragging event listeners. | |
google.maps.event.addListener($scope.eventData.emarker, 'dragstart', function () { | |
}); | |
google.maps.event.addListener($scope.eventData.emarker, 'drag', function () { | |
}); | |
google.maps.event.addListener($scope.eventData.emarker, 'dragend', function (event) { | |
localStorageService.set("lat", event.latLng.lat()); | |
localStorageService.set("long", event.latLng.lng()); | |
$scope.getLocationDetails(); | |
}); | |
google.maps.event.addListener($scope.eventData.emapForm, 'click', function (event) { | |
$scope.eventData.emarker.setPosition(event.latLng); | |
$scope.eventData.emapForm.panTo($scope.eventData.emarker.getPosition()); | |
localStorageService.set("lat", event.latLng.lat()); | |
localStorageService.set("long", event.latLng.lng()); | |
$scope.getLocationDetails(); | |
}); | |
} | |
$scope.resetEndTime = function (){ | |
$scope.eventData.endTime = null; | |
} | |
$rootScope.createEventValidation = function () { | |
if (!$scope.eventData.title) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_TITLE')); | |
} else if ($scope.eventData.eventCategory == null) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_CATEGORY')); | |
} else if (!$scope.eventData.permalink) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_PERMALINK')); | |
} else if (!$scope.eventData.description) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_DESCRIPTION')); | |
} | |
//see feedback issues #63203 | |
// else if (!$scope.evntform.website.$valid) { | |
// $rootScope.showalert("warning", $translate.instant('message.REQUIRE_SITE_URL_GROUP')); | |
// } | |
else if ($scope.eventData.repeat != null) { | |
if ($scope.eventData.endRepeat == null || $scope.eventData.scheduleDate.length == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_END_DATE_ERROR')); | |
} else if ($scope.eventData.scheduleDate.length > easysocial_count.event_repeat_limit) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_REPEAT_LIMIT_ERROR1') + $scope.eventData.scheduleDate.length + $translate.instant('message.EVENT_REPEAT_LIMIT_ERROR2')); | |
} else if ($scope.eventData.endDate != null) { | |
// if($scope.eventData.endTime==null){ | |
// $rootScope.showalert("warning",message.EVENT_END_TIME_ERROR); | |
// }else{ | |
if ($scope.eventData.endTime == null || $scope.eventData.endTime == "null") { | |
$scope.eventData.endTime = '00:00'; | |
} | |
var startDateValid = | |
new Date($scope.eventData.startDate + " " + $scope.eventData.startTime); | |
var endDateValid = | |
new Date($scope.eventData.endDate + " " + $scope.eventData.endTime); | |
if (startDateValid >= endDateValid) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_END_DATE_TIME_ERROR')); | |
} else { | |
$scope.createEvent(); | |
} | |
//} | |
} else { | |
$scope.createEvent(); | |
} | |
// else if($scope.eventData.repeat.value=='daily'){ | |
// if($scope.eventData.repeatDaily==null){ | |
// $rootScope.showalert("warning", message.EVENT_PERMALINK); | |
// } | |
// } | |
} else if ($scope.eventData.endDate != null) { | |
// if($scope.eventData.endTime==null){ | |
// $rootScope.showalert("warning",message.EVENT_END_TIME_ERROR); | |
// }else{ | |
if ($scope.eventData.endTime == null || $scope.eventData.endTime == "null") { | |
$scope.eventData.endTime = '00:00'; | |
} | |
var startDateValid = | |
new Date($scope.eventData.startDate + " " + $scope.eventData.startTime); | |
var endDateValid = | |
new Date($scope.eventData.endDate + " " + $scope.eventData.endTime); | |
if (startDateValid >= endDateValid) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_END_DATE_TIME_ERROR')); | |
} else { | |
$scope.createEvent(); | |
} | |
//} | |
} else { | |
$scope.createEvent(); | |
} | |
}; | |
$scope.createEvent = function () { | |
if ($scope.event_avatar) { | |
$rootScope.showloader(); | |
var data = $scope.eventData; | |
var options = new FileUploadOptions(); | |
options.fileKey = "file"; | |
options.fileName = $scope.event_avatar.substr($scope.event_avatar.lastIndexOf('/') + 1); | |
options.mimeType = "image/jpeg"; | |
// options.headers = { | |
// 'Content-Type': 'multipart/form-data; boundary=+++++' | |
// }; | |
options.chunkedMode = true; | |
var repeatArray; | |
if ($scope.eventData.repeat == null) { | |
repeatArray = { | |
type: 'none', | |
end: '' | |
}; | |
} else { | |
if ($scope.eventData.repeat.value == 'daily') { | |
var day = []; | |
if ($scope.eventData.repeatDaily != null) { | |
for (var i = 0; i < $scope.eventData.repeatDaily.length; i++) { | |
day[$scope.eventData.repeatDaily[i].index] = parseInt($scope.eventData.repeatDaily[i].value); | |
} | |
} | |
repeatArray = { | |
type: $scope.eventData.repeat.value, | |
daily: day, | |
end: $scope.eventData.endRepeat | |
}; | |
} else if ($scope.eventData.repeat.value == 'monthly' || | |
$scope.eventData.repeat.value == 'yearly') { | |
repeatArray = { | |
type: $scope.eventData.repeat.value, | |
end: $scope.eventData.endRepeat | |
}; | |
} | |
} | |
var params = new Object(); | |
var enddatetime = null; | |
if ((data.endDate == "null" || data.endDate == null) && (data.endTime == "null" || data.endTime == null)) { | |
enddatetime = null; | |
} else { | |
enddatetime = $filter('date')(data.endDate, 'yyyy-MM-dd') + " " + $filter('date')(data.endTime, 'HH:mm:ss'); | |
} | |
params.key = localStorageService.get('auth_key'), | |
params.category_id = data.eventCategory.value, | |
params.title = data.title, | |
params.parmalink = data.permalink, | |
params.description = data.description, | |
params.event_type = data.eventType, | |
params.startDatetime = $filter('date')(data.startDate, 'yyyy-MM-dd') + " " + $filter('date')(data.startTime, 'HH:mm:ss'), | |
params.endDatetime = enddatetime, | |
params.event_allday = data.eventAllDay ? 1 : 0, | |
//params.repeat = {type:'none', end:''}, | |
params.repeat = JSON.stringify(repeatArray), | |
params.website = data.website, | |
params.allowmaybe = data.maybeState ? 1 : 0, | |
params.allownotgoingguest = data.goingState ? 1 : 0, | |
params.guestlimit = data.guestLimit, | |
params.photo_albums = data.albums ? 1 : 0, | |
params.announcement = data.announcements ? 1 : 0, | |
params.discussions = data.discussions ? 1 : 0, | |
// params.location = JSON.stringify({"address1":"Road No.10","address2":"","city":"Pune","state":"Maharashtra","zip":"411038","country":"India","components":{"street_number":"116","route":"Road No.10","sublocality_level_2":"Dahanukar Colony","sublocality_level_1":"Kothrud","locality":"Pune","administrative_area_level_2":"Pune","administrative_area_level_1":"Maharashtra","country":"India","postal_code":"411038"},"address":"116, Rd No.10, Dahanukar Colony, Kothrud, Pune, Maharashtra 411038, India","latitude":18.497263,"longitude":73.81242599999996}), | |
params.location = JSON.stringify(localStorageService.get("address")), | |
options.params = params; | |
var ft = new FileTransfer(); | |
ft.upload($scope.event_avatar, localStorageService.get('url') + "/index.php?option=com_api&app=easysocial&resource=event&format=raw", $scope.eventSuccess, $scope.eventError, options); | |
} else { | |
$rootScope.showloader(); | |
easysocialService.createEvent($scope.eventData).then(function (data) { | |
if (data.success) { | |
$rootScope.showalert("success", data.message); | |
$route.reload(); | |
} else { | |
$rootScope.showalert("error", data.message); | |
$rootScope.hideloader(); | |
} | |
}); | |
} | |
}; | |
$scope.eventSuccess = function (r) { | |
var temp = JSON.parse(r.response); | |
$rootScope.hideloader(); | |
if (temp.success) { | |
$rootScope.showalert("success", temp.message); | |
$route.reload(); | |
} else { | |
$rootScope.showalert("error", temp.message); | |
} | |
}; | |
$scope.eventError = function (error) { | |
$rootScope.hideloader(); | |
$rootScope.showalert("error", $translate.instant('message.EVENT_CREATE_ERROR')); | |
}; | |
$scope.weekTemplate = [{ | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_SUNDAY'), | |
value: '0', | |
index: 6 | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_MONDAY'), | |
value: '1', | |
index: 0 | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_TUESDAY'), | |
value: '2', | |
index: 1 | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_WEDNESDAY'), | |
value: '3', | |
index: 2 | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_THURSDAY'), | |
value: '4', | |
index: 3 | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_FRIDAY'), | |
value: '5', | |
index: 4 | |
}, { | |
name: $translate.instant('label.CREATE_EVENT_REPEATE_SATURDAY'), | |
value: '6', | |
index: 5 | |
}]; | |
$scope.eventAllDaySet = function (element) { | |
if (element == 'true' || element == true) { | |
$scope.eventData.startTime = '00:00'; | |
$scope.eventAllDayStatus = true; | |
if ($scope.eventData.endDate == null || $scope.eventData.endDate == "null") { | |
$scope.eventData.endTime = null; | |
} else { | |
$scope.eventData.endTime = '00:00'; | |
} | |
} else { | |
$scope.eventAllDayStatus = false; | |
} | |
}; | |
$scope.changeDailyRepeat = function () { | |
if ($scope.eventData.repeat != null) { | |
if ($scope.eventData.startDate == null) { | |
$rootScope.showalert("warning", $translate.instant('message.EVENT_START_DATE_ERROR')); | |
} else if ($scope.eventData.endRepeat == null) { | |
//$rootScope.showalert("warning", message.EVENT_END_DATE_ERROR); | |
} else { | |
var start = new Date($scope.eventData.startDate); | |
var end = new Date($scope.eventData.endRepeat); | |
$scope.eventData.scheduleDate = []; | |
//Montly repeat case | |
if ($scope.eventData.repeat.value == 'monthly') { | |
var startTemp = new Date($scope.eventData.startDate); | |
var nextMonthDate; // = new Date(startTemp.setMonth(startTemp.getMonth()+1)); | |
while (start <= end) { | |
nextMonthDate = new Date(startTemp.setMonth(startTemp.getMonth() + 1)); | |
if ((start.getMonth() + 1) % 12 != nextMonthDate.getMonth()) { | |
startTemp = new Date(start); | |
var monthDay = new Date(nextMonthDate.getFullYear(), start.getMonth() + 2, 0).getDate(); | |
nextMonthDate = new Date(nextMonthDate.getFullYear(), start.getMonth() + 1, monthDay); | |
if (nextMonthDate <= end) { | |
$scope.eventData.scheduleDate.push($filter('date')(nextMonthDate, 'yyyy-MM-dd')); | |
} | |
nextMonthDate = new Date(nextMonthDate.getFullYear(), start.getMonth() + 2, start.getDate()); | |
if (nextMonthDate <= end) { | |
$scope.eventData.scheduleDate.push($filter('date')(nextMonthDate, 'yyyy-MM-dd')); | |
} | |
} else { | |
if (nextMonthDate <= end) { | |
$scope.eventData.scheduleDate.push($filter('date')(nextMonthDate, 'yyyy-MM-dd')); | |
} | |
} | |
start = new Date(nextMonthDate); | |
startTemp = new Date(nextMonthDate); | |
} | |
$scope.limitOfScheduleDate(); | |
} | |
//Daily repeat case | |
if ($scope.eventData.repeat.value == 'daily') { | |
var day = []; | |
if ($scope.eventData.repeatDaily != null) { | |
for (var i = 0; i < $scope.eventData.repeatDaily.length; i++) { | |
day.push($scope.eventData.repeatDaily[i].value); | |
} | |
while (start <= end) { | |
var newDate = start.setDate(start.getDate() + 1); | |
start = new Date(newDate); | |
if (day.indexOf('' + start.getDay() + '') != -1) { | |
if (start <= end) { | |
$scope.eventData.scheduleDate.push($filter('date')(start, 'yyyy-MM-dd')); | |
} | |
} | |
} | |
} | |
$scope.limitOfScheduleDate(); | |
} | |
//Yearly repeat case | |
if ($scope.eventData.repeat.value == 'yearly') { | |
var startTemp = new Date($scope.eventData.startDate); | |
var startDate = startTemp.getDate(); | |
var startMonth = startTemp.getMonth(); | |
var startYear = startTemp.getFullYear(); | |
var yearCount = 1; | |
while (start <= end) { | |
var newDate = new Date(startYear + yearCount, startMonth, startDate); | |
if ((start.getMonth()) % 12 != newDate.getMonth()) { | |
var monthDay = new Date(newDate.getFullYear(), startTemp.getMonth() + 1, 0).getDate(); | |
newDate = new Date(startYear + yearCount, startTemp.getMonth(), monthDay); | |
if (newDate <= end) { | |
$scope.eventData.scheduleDate.push($filter('date')(newDate, 'yyyy-MM-dd')); | |
} | |
} else { | |
if (newDate <= end) { | |
$scope.eventData.scheduleDate.push($filter('date')(newDate, 'yyyy-MM-dd')); | |
} | |
} | |
start = new Date(newDate); | |
startTemp = new Date(newDate); | |
yearCount++; | |
} | |
$scope.limitOfScheduleDate(); | |
} | |
} | |
} | |
}; | |
//Limit out of schedule date then throw warrning message | |
$scope.limitOfScheduleDate = function () { | |
if ($scope.eventData.scheduleDate.length > easysocial_count.event_repeat_limit) { | |
$rootScope.showalert("warning", | |
$translate.instant('message.EVENT_REPEAT_LIMIT_ERROR1') + | |
$scope.eventData.scheduleDate.length + | |
$translate.instant('message.EVENT_REPEAT_LIMIT_ERROR2')); | |
$scope.eventData.scheduleDate = []; | |
} | |
} | |
// For navigating to group detail | |
$scope.viewEventDetail = function (id) { | |
if (id) { | |
localStorageService.set("eventid", id); | |
$rootScope.EventID = id; | |
} | |
$location.path(pathConstant.SOCIAL_EVENTDETAIL_VIEW_PATH); | |
}; | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
case "eventdetail": | |
//Event detail case | |
$scope.moredetailfalg = false; | |
localStorageService.set("startLimit", "0"); | |
if (checkConnection()) { | |
localStorageService.set("groupid", null); | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
//to select menu | |
$scope.devicePlatform = device.platform; | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
localStorageService.set("clusterType", "event"); | |
$scope.loaderBtn = true; | |
//localStorageService.set("newsfeedFilter", "me"); | |
/* event profile Data */ | |
easysocialService.eventdetail().then(function (data) { | |
localStorageService.set("eventdetail_dialog", data); | |
if (data.length > 0) { | |
$scope.profileData = data[0]; | |
$scope.profileData.guests = parseInt($scope.profileData.guests); | |
$scope.lat = $scope.profileData.latitude; | |
$scope.long = $scope.profileData.longitude; | |
$rootScope.title = data[0].title; | |
$rootScope.isAlbumMember =data[0].isMember; | |
$scope.shareTitle = $translate.instant('label.WRITEON') + " " + $rootScope.title + $translate.instant('label.EVENTWALL'); | |
} | |
}); | |
$rootScope.hideloader(); | |
} | |
/* Event newsfeed shown on event details */ | |
easysocialService.eventnewsfeed().then(function (data) { | |
if (!data.code) | |
$scope.streams = data; | |
// To load more group streams | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.stream_limit); | |
easysocialService.eventnewsfeed().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.stream_limit); | |
} else { | |
$scope.streams = $scope.streams.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
$rootScope.hideloader(); | |
}); | |
} | |
// For navigating to event more detail page | |
$scope.gotoMoreEventDetail = function () { | |
$scope.moredetailfalg = true; | |
var place = new google.maps.LatLng($scope.lat, $scope.long); | |
mapForm = new google.maps.Map(document.getElementById('mapCanvas'), { | |
center: place, | |
zoom: 15, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}); | |
marker = new google.maps.Marker({ | |
position: place, | |
map: mapForm | |
//icon: $rootScope.iconMarker | |
}); | |
}; | |
//get event guests. | |
$scope.get_guest = function (id,isowner) { | |
/* event guest Data */ | |
if (id) { | |
localStorageService.set("eventowner", isowner); | |
localStorageService.set("groupid", id); | |
} | |
$rootScope.friends = ""; | |
$location.path(pathConstant.SOCIAL_EVENT_GUESTS_VIEW_PATH); | |
} | |
//event album | |
$scope.eventAlbum = function () { | |
localStorageService.set("albumEventType", "event"); | |
} | |
$scope.openEventInvite = function () { | |
localStorageService.set("toggle", "event_invite"); | |
$rootScope.toggle('event_invite', 'on'); | |
$scope.tags = ""; | |
$scope.invited = false; | |
}; | |
$scope.sendEventInvite = function () { | |
if ($scope.tags.length == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.FRIEND_EVENT_INVITE_MESSAGE_ERROR')); | |
} else { | |
$rootScope.showloader(); | |
easysocialService.eventInvite($scope.tags).then(function (data) { | |
if (!data.code) { | |
if (data.status) { | |
//$rootScope.showalert("success", data.message); | |
$scope.toggleAction('event_invite'); | |
$rootScope.hideloader(); | |
if ((data.not_invtited.length != 0) && (data.invited.length != 0)) { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_INVITE_SUCCESS') + ' ' + data.invited.toString() + '. ' + $translate.instant('message.FRIEND_NON_INVITE_SUCCESS') + ' ' + data.not_invtited.toString()); | |
} else if ((data.not_invtited.length == 0) && (data.invited.length != 0)) { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_INVITE_SUCCESS') + ' ' + data.invited.toString()); | |
} else if ((data.not_invtited.length != 0) && (data.invited.length == 0)) { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_EVENT_INVITE_ALREADY') + data.not_invtited.toString()); | |
} else { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_INVITE_SUCCESS') + ' ' + data.invited.toString() + '. ' + $translate.instant('message.FRIEND_NON_INVITE_SUCCESS') + ' ' + data.not_invtited.toString() + ''); | |
} | |
} else { | |
$rootScope.showalert("error", data.message); | |
$rootScope.hideloader(); | |
} | |
} else { | |
$rootScope.hideloader(); | |
} | |
}); | |
} | |
}; | |
break; | |
case "videodetail": | |
$scope.setVideoFilter = function (type, sort,categoryId) { | |
localStorageService.set("videolistFilter", type); | |
localStorageService.set("sort", sort); | |
localStorageService.set("categoryid", categoryId); | |
$location.path(pathConstant.SOCIAL_VIDEOLIST_VIEW_PATH); | |
$route.reload(); | |
} | |
break; | |
case "conversations": | |
if (checkConnection()) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
// Method to load conversations | |
$scope.showConversationlist = function () { | |
localStorageService.set("startLimit", "0"); | |
localStorageService.set("limitIs", easysocial_count.conversations_limit); | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
$scope.conversations = ""; | |
$scope.loaderBtn = true; | |
easysocialService.getconversations().then(function (data) { | |
$scope.dataIs = []; | |
if (!data.code) { | |
//Conversation participant user name and profile picture | |
angular.forEach(data.data, function (value, key) { | |
var dataObj = value; | |
$scope.participant = value.participant; | |
$scope.username = []; | |
$scope.userImage = ""; | |
angular.forEach($scope.participant, function (value, key) { | |
$scope.username.push(value.name); | |
$scope.userImage = value.image.image_medium; | |
}); | |
$scope.userObj = { | |
"usernames": $scope.username.toString(), | |
"userimage": $scope.userImage | |
}; | |
var obj = angular.extend(dataObj, $scope.userObj); | |
}); | |
$scope.conversations = data.data; | |
} | |
$rootScope.hideloader(); | |
// To load more conversations | |
$scope.loadMore = function () { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.conversations_limit); | |
easysocialService.getconversations().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0 || data.data == null) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.conversations_limit); | |
} else { | |
angular.forEach(data.data, function (value, key) { | |
var dataObj = value; | |
$scope.participant = value.participant; | |
$scope.username = []; | |
$scope.userImage = ""; | |
angular.forEach($scope.participant, function (value, key) { | |
$scope.username.push(value.name); | |
$scope.userImage = value.image.image_medium; | |
}); | |
$scope.userObj = { | |
"usernames": $scope.username.toString(), | |
"userimage": $scope.userImage | |
}; | |
var obj = angular.extend(dataObj, $scope.userObj); | |
}); | |
$scope.conversations = $scope.conversations.concat(data.data); | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
}); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
}; | |
// For navigating to single conversation page | |
$scope.openConversationView = function () { | |
$scope.messages = ""; | |
$rootScope.toggle('conversation_dialog', 'on'); | |
localStorageService.set("toggle", "conversation_dialog"); | |
}; | |
// For navigating to single conversation page | |
$scope.gotoConversationView = function (element) { | |
$rootScope.showloader(); | |
$scope.upwordLoader = 0; | |
localStorageService.set("limitIs", easysocial_count.conversations_limit); | |
localStorageService.set("startLimit", "0"); | |
//Auto refresh every 10 sec. | |
// if(localStorageService.get("toggle")=='conversation_dialog'){ | |
// setTimeout($scope.gotoConversationView, 10000); | |
// }else{ | |
// return; | |
// } | |
if (element != undefined) { | |
localStorageService.set("conversationId", element.conversation.conversion_id); | |
$scope.conversationstitle = element.conversation.usernames; | |
} | |
$scope.loaderBtn = true; | |
//Get list of messages | |
easysocialService.getmessages().then(function (data) { | |
if (!data.code) { | |
$rootScope.hideloader(); | |
$scope.messages = data.data; | |
if($scope.messages.length >= 10) | |
$scope.upwordLoader = 1; | |
$scope.message.recipientIds = []; | |
angular.forEach(data.participant, function (value, key) { | |
if (data.participant[key].hasOwnProperty('id')) { | |
$scope.message.recipientIds.push(data.participant[key].id); | |
} | |
}); | |
localStorageService.set("recipientIds", $scope.message.recipientIds); | |
/* Loadmore for Conversation */ | |
if (data.data.length == 10) { | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.conversations_limit); | |
easysocialService.getmessages().then(function (data) { | |
$scope.loaderBtn = false; | |
$scope.upwordLoader = 0; | |
if (data.data.length >= 1) { | |
$scope.loaderBtn = true; | |
$scope.upwordLoader = 1; | |
} | |
}); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.conversations_limit); | |
} | |
//After 1 sec it scroll to down | |
setTimeout($scope.scrollbottom, 1000); | |
} | |
$rootScope.hideloader(); | |
// To load more groups | |
$scope.loadMore = function () { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.conversations_limit); | |
easysocialService.getmessages().then(function (data) { | |
$scope.upwordLoader = 0; | |
if (!data.code) { | |
if (data.data.length == 0) { | |
$scope.loaderBtn = false; | |
$scope.upwordLoader = 0; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) - easysocial_count.conversations_limit); | |
}else if($scope.messages >= 1){ | |
$scope.upwordLoader = 1; | |
} | |
else { | |
$scope.messages = data.data.concat($scope.messages); | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
}); | |
$scope.to_trusted = function (html_code) { | |
return $sce.trustAsHtml(html_code.replace(/\n\r?/g, '<br />')); | |
//$rootScope.hideloader(); | |
}; | |
// Method to post reply | |
$scope.postMyReply = function () { | |
if ($scope.myreply.reply) { | |
$rootScope.showloader(); | |
easysocialService.postreply($scope.myreply.reply).then(function (data) { | |
if (data.status) { | |
$scope.myreply.reply = ""; | |
$scope.gotoConversationView(); | |
} else { | |
$rootScope.showalert("error", $translate.instant('message.REPLY_SENT_UNSUCCESS')); | |
$rootScope.hideloader(); | |
} | |
}); | |
} else { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_REPLY')); | |
} | |
} | |
$scope.scrollbottom = function () { | |
$location.hash('scrollBottom'); | |
$anchorScroll(); | |
}; | |
}; | |
// Method for deleting conversation | |
$scope.deleteConversation = function (element) { | |
navigator.notification.confirm($translate.instant('message.DELETE_CONVERSATION'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
localStorageService.set("conversationId", element.conversation.conversion_id); | |
easysocialService.deleteconversation().then(function (data) { | |
if (!data.code) { | |
element.conversation = ""; | |
$rootScope.showalert("success", data.message); | |
//$rootScope.showalert(message.CONVERSATION_DELETED_SUCCESS); | |
$scope.refresh(); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
}; | |
// Method for searching recipients | |
$scope.search_recipients = function () { | |
$rootScope.showloader(); | |
$rootScope.peoples = ""; | |
$rootScope.showloader(); | |
var searctTxt = $scope.people.search; | |
easysocialService.search_people(searctTxt).then(function (data) { | |
if (!data.code) { | |
$rootScope.peoples = data.user; | |
} | |
$rootScope.hideloader(); | |
}); | |
}; | |
// Method for adding recipients | |
$scope.addRecipient = function (element) { | |
var obj = element.profileData; | |
var recipient = localStorageService.get("recipients"); | |
var newObj = []; | |
var flag = 0; | |
if (recipient) { | |
for (var i = 0; i < recipient.length; i++) { | |
if (recipient[i].id == obj.id) { | |
flag = 1; | |
} | |
newObj.push(recipient[i]); | |
} | |
} | |
if (flag == 0) { | |
newObj.push(obj); | |
} | |
localStorageService.set("recipients", JSON.stringify(newObj)); | |
var recipientList = localStorageService.get("recipients"); | |
$scope.message.recipient = ""; | |
$scope.message.recipientIds = []; | |
for (var k = 0; k < recipientList.length; k++) { | |
if ($scope.message.recipient) { | |
$scope.message.recipient += ", "; | |
} | |
$scope.message.recipient += recipientList[k].name; | |
$scope.message.recipientIds.push(recipientList[k].id); | |
} | |
}; | |
// For navigating to message view page | |
$scope.gotoMessageView = function () { | |
$rootScope.peoples = ""; | |
$scope.people.search = ""; | |
$rootScope.toggle('composemessage_dialog', 'on'); | |
localStorageService.set("toggle", "composemessage_dialog"); | |
localStorageService.set("recipients", ""); | |
localStorageService.set("recipientIds", ""); | |
$scope.tags = ""; | |
$scope.message.recipient = ""; | |
$scope.message.recipientIds = []; | |
$scope.message.content = ""; | |
// Method to send message | |
$scope.sendMessage = function () { | |
$scope.message.recipientIds = []; | |
angular.forEach($scope.tags, function (value, key) { | |
var user = value; | |
angular.forEach(user, function (value, key) { | |
if (key == "id") { | |
$scope.message.recipientIds.push(value); | |
} | |
}); | |
}); | |
if ($scope.message.recipientIds.length == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_RECIPIENT_NAME')); | |
} else if (!$scope.message.content) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_MESSAGE')); | |
} else if ($scope.message.recipientIds && $scope.message.content) { | |
$rootScope.showloader(); | |
localStorageService.set("conversationId", "0"); | |
localStorageService.set("recipientIds", $scope.message.recipientIds); | |
$scope.myreply.reply = $scope.message.content; | |
easysocialService.postreply($scope.myreply.reply).then(function (data) { | |
//if (!data.code){ | |
if (data.status) { | |
$rootScope.showalert("success", data.message); | |
$scope.refresh(); | |
} else { | |
$rootScope.showalert("warning", data.message); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
} | |
}; | |
$scope.showConversationlist(); | |
} | |
break; | |
case "albumslist": | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
$rootScope.albums = ""; | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", "0"); | |
$scope.albumuserid = localStorageService.get("currentuid"); | |
$scope.type = 'user'; | |
//Album list as per the album event type. | |
if (localStorageService.get("albumEventType") == "event") { | |
$scope.albumuserid = localStorageService.get("eventid"); | |
$scope.type = 'event'; | |
} | |
//case added by pratiksha to show the album details for the group 23jan | |
else if (localStorageService.get("albumEventType") == "group") { | |
$scope.albumuserid = localStorageService.get("groupid"); | |
$scope.type = 'group'; | |
} | |
else | |
{ | |
} | |
easysocialService.getAlbumsList($scope.albumuserid, $scope.type).then(function (data) { | |
if (!data.code) { | |
$rootScope.albums = data; | |
if($scope.type == 'event') | |
$scope.isAlbumOwner = $rootScope.isAlbumMember; | |
else if($scope.type == 'group') | |
$scope.isAlbumOwner = $rootScope.memberFlag; | |
else if(data.length){ | |
$scope.isAlbumOwner = $rootScope.albums[0].isowner; | |
} | |
} | |
$rootScope.hideloader(); | |
// To load more albumes list | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.album_pagination_limit); | |
easysocialService.getAlbumsList($scope.albumuserid,$scope.type).then(function (data) { | |
if (!data.code) { | |
if (data.length != 0) { | |
$scope.albums = $scope.albums.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
$rootScope.albumflag = 0; | |
}); | |
//Open album photo grid overlay | |
$scope.showAlbumPhotos = function () { | |
$scope.addPhotoDiv = false; | |
$rootScope.albumPhotos = ""; | |
$rootScope.showloader(); | |
// $rootScope.toggle('albumphots_dialog', 'on'); | |
// localStorageService.set("toggle", "albumphots_dialog"); | |
$scope.newAlbumPhotos = []; | |
} | |
//Get the album photos list on album id | |
$scope.albumPhotosView = function (title, id, photosCount) { | |
$rootScope.showloader(); | |
$rootScope.uploadAlbumImagesInprogress = false; | |
$rootScope.title = title; | |
$scope.albumId = id; | |
$scope.addPhotoDiv = false; | |
$rootScope.albumPhotos = ""; | |
localStorageService.set("startLimit", 0); | |
localStorageService.set("limitIs", easysocial_count.photos_pagination_limit); | |
$rootScope.photouserid = localStorageService.get("currentuid"); | |
if (photosCount) { | |
$rootScope.photosCountTemp = photosCount; | |
} else { | |
photosCount = $rootScope.photosCountTemp; | |
} | |
//Load more hide/show on total photos count | |
$rootScope.photosLoadMore = photosCount - (localStorageService.get("startLimit") + easysocial_count.photos_pagination_limit); | |
$rootScope.photosLoadMore = $rootScope.photosLoadMore <= 0 ? false : true; | |
if ($rootScope.albumphotoflag == 1) { | |
$rootScope.photouserid = ''; | |
} | |
easysocialService.getAlbumPhotos(id, $rootScope.photouserid).then(function (data) { | |
if (!data.code) { | |
$rootScope.albumPhotos = data; | |
$rootScope.toggle('albumphots_dialog', 'on'); | |
localStorageService.set("toggle", "albumphots_dialog"); | |
} | |
$rootScope.hideloader(); | |
$scope.loadMore = function () { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.photos_pagination_limit)); | |
$rootScope.photosLoadMore = photosCount - (parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.photos_pagination_limit)); | |
$rootScope.photosLoadMore = $rootScope.photosLoadMore <= 0 ? false : true; | |
easysocialService.getAlbumPhotos(id).then(function (data) { | |
if (!data.code) { | |
$rootScope.albumPhotos = $rootScope.albumPhotos.concat(data); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
}); | |
}; | |
//Open create album with initialize | |
$scope.albumNewForm = function () { | |
$rootScope.toggle('newalbum_dialog', 'on'); | |
localStorageService.set("toggle", "newalbum_dialog"); | |
$scope.album_cover = ""; | |
//$scope.saveAlbum = true; | |
$scope.multiImageDiv = false; | |
$scope.album_title = ""; | |
$scope.album_description = ""; | |
$scope.newAlbumPhotos = []; | |
}; | |
//Create new album | |
$scope.saveAlbumData = function () { | |
if (!$scope.album_title) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_ALBUM_TITLE')); | |
} | |
/*else if (!$scope.album_description) | |
{ | |
$rootScope.showalert("warning", message.REQUIRE_ALBUM_DESCRIPTION); | |
}*/ | |
else { | |
$rootScope.showloader(); | |
$scope.albumdata = { | |
title: $scope.album_title, | |
description: $scope.album_description, | |
}; | |
//Image is not attache then simple service is called | |
if ($scope.album_cover == "") { | |
if ($rootScope.albumflag == 1) { | |
$scope.albumType = 'event'; | |
} | |
if (localStorageService.get("albumEventType") == "event") { | |
$scope.type = 'event'; | |
} else if (localStorageService.get("albumEventType") == "group") { | |
$scope.type = 'group'; | |
} | |
easysocialService.createalbum($scope.albumdata, $scope.type).then(function (data) { | |
if (data.id) { | |
$rootScope.showalert("success", $translate.instant('message.ALBUM_CREATED')); | |
$rootScope.photosCountTemp = 0; | |
$scope.toggleAction('newalbum_dialog'); | |
$scope.showAlbumPhotos(); | |
$scope.albumPhotosView(data.title, data.id); | |
} else { | |
$rootScope.showalert("error", data.message); | |
} | |
$rootScope.hideloader(); | |
}); | |
} else { | |
//If image is attched then upload image is working | |
var uId = ''; | |
var type = ''; | |
if (localStorageService.get("albumEventType") == "event") { | |
uId = localStorageService.get("eventid"); | |
type = 'event'; | |
} else if (localStorageService.get("albumEventType") == "group") { | |
uId = localStorageService.get("groupid"); | |
type = 'group'; | |
} else { | |
uId = localStorageService.get('userid'); | |
type = 'user'; | |
} | |
var options = new FileUploadOptions(); | |
options.fileKey = "file"; | |
options.fileName = $scope.album_cover.substr($scope.album_cover.lastIndexOf('/') + 1); | |
options.mimeType = "image/jpeg"; | |
var params = new Object(); | |
params.key = localStorageService.get('auth_key'), | |
params.title = $scope.albumdata.title, | |
params.description = $scope.albumdata.description, | |
params.uid = uId, | |
params.type = type, | |
options.params = params; | |
options.chunkedMode = false; | |
var ft = new FileTransfer(); | |
ft.upload($scope.album_cover, localStorageService.get('url') + "/index.php?option=com_api&app=easysocial&resource=album&format=raw", $scope.newAlbumDirSuccess, $scope.newAlbumfail, options); | |
} | |
} | |
}; | |
//Open the multi image select gallery function | |
$scope.multiImage = function () { | |
window.imagePicker.getPictures(function (results) { | |
for (var i = 0; i < results.length; i++) { | |
var obj = { | |
path: results[i], | |
progress: '1%' | |
}; | |
$scope.newAlbumPhotos.push(obj); | |
} | |
}, function (error) { | |
console.log('Error: ' + error); | |
}, { | |
maximumImagesCount: 10, | |
width: 800 | |
}); | |
}; | |
//Delect the particular album | |
$scope.deleteAlbum = function (albumid) { | |
navigator.notification.confirm($translate.instant('message.DELETE_ALBUM'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.deletealbum(albumid).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", $translate.instant('message.ALBUM_DELETED_SUCCESS')); | |
$route.reload(); | |
} | |
$rootScope.hideloader(); | |
}); | |
$rootScope.showloader(); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
}; | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
//LeaderBoard case | |
case "Leaderboard": | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
//setting start limit. | |
localStorageService.set("startLimit", 0); | |
//to select menu | |
$rootScope.selected = $rootScope.marr[window.location.hash]; | |
$scope.loaderBtn = true; | |
$rootScope.showloader(); | |
/* Leaders profile Data */ | |
easysocialService.getLeaders().then(function (data) { | |
$scope.profileData = data; | |
$rootScope.hideloader(); | |
}); | |
// To load more leaders list | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.leaderboard_pagination_limit); | |
easysocialService.getLeaders().then(function (data) { | |
if (!data.code) { | |
$scope.profileData = $scope.profileData.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
case "videolist": | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
$rootScope.showloader(); | |
//Initialize limit | |
localStorageService.set("startLimit", "0"); | |
localStorageService.set("limitIs", easysocial_count.video_limit); | |
localStorageService.set("clusterType", "video"); | |
//Platform set for location map view | |
$scope.devicePlatform = device.platform; | |
//Get video list case | |
easysocialService.videoslist().then(function (data) { | |
if (!data.code) { | |
$scope.videos = data.video; | |
$rootScope.loggeduser=localStorageService.get("username"); | |
} | |
$rootScope.hideloader(); | |
var videolistFilter = localStorageService.get("videolistFilter"); | |
var frequest = "#vfilter" | |
if (videolistFilter == 'all' || videolistFilter == 'featured' || | |
videolistFilter == 'mine') { | |
frequest = "#v" + localStorageService.get("videolistFilter"); | |
} | |
$(frequest).addClass("active"); | |
$scope.loaderBtn = true; | |
$scope.loadMore = function () { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.event_limit); | |
if ($scope.loaderBtn) { | |
easysocialService.videoslist().then(function (data) { | |
if (!data.code) { | |
if (data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.event_limit); | |
$rootScope.hideloader(); | |
} else { | |
$rootScope.hideloader(); | |
} | |
} | |
}); | |
} else { | |
$rootScope.hideloader(); | |
} | |
} | |
}; | |
}); | |
//Get Video categories list and set to local storage | |
if (localStorageService.get("videocatlist") == null || localStorageService.get("videocatlist") == '' || localStorageService.get("videocatlist")) { | |
easysocialService.videoslist().then(function (data) { | |
var catdataArray = []; | |
/* Video categorie array created and assign to model */ | |
angular.forEach(data.categories, function (value, key) { | |
var category = value | |
catdataArray.push({ | |
"value": category.categoryid, | |
"title": category.title | |
}); | |
}); | |
localStorageService.set('videocatlist', JSON.stringify(catdataArray)); | |
$rootScope.videoCategory = localStorageService.get('videocatlist'); | |
}); | |
} else { | |
$rootScope.videoCategory = localStorageService.get('videocatlist'); | |
} | |
//Video open filter function. | |
$scope.openFilter = function () { | |
$rootScope.toggle('videofilter_dialog', 'on'); | |
localStorageService.set("toggle", "videofilter_dialog"); | |
} | |
//Video setting icon actions | |
$scope.isAction = function (video_id, action) { | |
localStorageService.set("videoid", video_id); | |
$rootScope.showloader(); | |
easysocialService.isAction(video_id,action).then(function (data) { | |
if(video_id){ | |
$scope.videoData = data; | |
$rootScope.hideloader(); | |
$route.reload(); | |
} | |
}); | |
if(action=="featured") { | |
$rootScope.showalert("success", $translate.instant('message.FEATURED_VIDEO')); | |
} | |
if(action=="unfeatured") { | |
$rootScope.showalert("success", $translate.instant('message.UNFEATURED_VIDEO')); | |
} | |
if(action=="delete") { | |
$rootScope.showalert("success", $translate.instant('message.DELETE_VIDEO')); | |
} | |
if(action=="edit") { | |
$scope.videoid = localStorageService.get("videoid"); | |
$rootScope.toggle('newvideo_dialog', 'on'); | |
localStorageService.set("toggle", "newvideo_dialog"); | |
$scope.isLocationMap = false; | |
} | |
} | |
$scope.updateVideo = function (action) { | |
if (checkConnection()) { | |
var data = $scope.videoData; | |
var params = new Object(); | |
params.key = localStorageService.get('auth_key'), | |
params.uid = localStorageService.get('userId'), | |
params.category_id = data.videoCategory.value, | |
params.title = data.title, | |
params.description = data.description, | |
params.path = data.path, | |
params.tags = data.tags, | |
params.sharePrivacy = data.sharePrivacy, | |
params.location = JSON.stringify(localStorageService.get("address")), | |
$rootScope.showloader(); | |
easysocialService.videolinkupdate($scope.videoData,action).then(function (data) { | |
if (data.success) { | |
$rootScope.showalert("success", data.message); | |
$route.reload(); | |
$location.path(pathConstant.SOCIAL_VIDEOLIST_VIEW_PATH); | |
} else { | |
$rootScope.showalert("error", $translate.instant('message.VIDEO_UPDATE_FAILED')); | |
$rootScope.hideloader(); | |
} | |
}); | |
} | |
}; | |
//Video filter function. | |
$scope.setVideoFilter = function (type, sort,categoryId) { | |
localStorageService.set("videolistFilter", type); | |
localStorageService.set("sort", sort); | |
localStorageService.set("categoryid", categoryId); | |
$scope.toggleAction('filter_dialog'); | |
$route.reload(); | |
} | |
//Upload video | |
$scope.gotoNewVideo = function () { | |
$rootScope.toggle('newvideo_dialog', 'on'); | |
localStorageService.set("toggle", "newvideo_dialog"); | |
$scope.isLocationMap = false; | |
}; | |
//map initialization for video | |
$scope.mapInitialization = function () { | |
var place = new google.maps.LatLng(localStorageService.get("lat"), | |
localStorageService.get("long")); | |
$scope.videoData.vmapForm = new google.maps.Map(document.getElementById('mapCanvas'), { | |
center: place, | |
zoom: 15, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}); | |
$scope.videoData.vmarker = new google.maps.Marker({ | |
position: place, | |
map: $scope.videoData.vmapForm, | |
draggable: true | |
}); | |
var mapForm = $scope.videoData.vmapForm; | |
//markers.push(marker); | |
var centerControlDiv = document.createElement('div'); | |
var centerControl = new CenterControl(centerControlDiv, $scope.videoData.vmapForm); | |
$scope.videoData.vmapForm.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(centerControlDiv); | |
function CenterControl(controlDiv, mapForm) { | |
// Set CSS for the control border | |
var controlUI = document.createElement('div'); | |
controlUI.style.backgroundColor = '#fff'; | |
controlUI.style.border = '2px solid #fff'; | |
controlUI.style.borderRadius = '3px'; | |
controlUI.style.boxShadow = '0 2px 6px rgba(0,0,0,.3)'; | |
controlUI.style.cursor = 'pointer'; | |
controlUI.style.marginBottom = '22px'; | |
controlUI.style.textAlign = 'center'; | |
controlUI.title = 'Click to recenter the map'; | |
controlDiv.appendChild(controlUI); | |
// Set CSS for the control interior | |
var controlText = document.createElement('div'); | |
controlText.style.color = 'rgb(25,25,25)'; | |
controlText.style.fontFamily = 'Roboto,Arial,sans-serif'; | |
controlText.style.fontSize = '16px'; | |
controlText.style.lineHeight = '38px'; | |
controlText.style.height = '38px'; | |
controlText.style.paddingLeft = '5px'; | |
controlText.style.paddingRight = '5px'; | |
controlText.innerHTML = '<i style="" class="fa fa-street-view fa-lg streetColor fa-lg-set"></i>'; | |
controlUI.appendChild(controlText); | |
// Setup the click video listeners: simply set the map to place | |
google.maps.video.addDomListener(controlUI, 'click', function () { | |
marker.setPosition(place); | |
$scope.videoData.vmapForm.setCenter(place); | |
}); | |
} | |
// Add dragging event listeners. | |
google.maps.video.addListener($scope.videoData.vmarker, 'dragstart', function () { | |
}); | |
google.maps.video.addListener($scope.videoData.vmarker, 'drag', function () { | |
}); | |
google.maps.video.addListener($scope.videoData.vmarker, 'dragend', function (video) { | |
localStorageService.set("lat", video.latLng.lat()); | |
localStorageService.set("long", video.latLng.lng()); | |
$scope.getLocationDetails(); | |
}); | |
google.maps.event.addListener($scope.videoData.vmapForm, 'click', function (video) { | |
$scope.videoData.vmarker.setPosition(video.latLng); | |
$scope.videoData.vmapForm.panTo($scope.videoData.vmarker.getPosition()); | |
localStorageService.set("lat", video.latLng.lat()); | |
localStorageService.set("long", video.latLng.lng()); | |
$scope.getLocationDetails(); | |
}); | |
} | |
// video upload validation | |
$scope.uploadVideoValidation = function () { | |
if (!$scope.videoData.title) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_TITLE')); | |
} else if ($scope.videoData.videoCategory == null) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_CATEGORY')); | |
} /*else if (!$scope.videoData.description) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_DESCRIPTION')); | |
} else if (!$scope.videoData.videoType) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_TYPE')); | |
}*/else if (!$scope.videoData.path) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_LINK')); | |
} /*else if (!$scope.videoData.tags) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_PEOPLE')); | |
} else if (!$scope.videoData.sharePrivacy) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_PRIVACY')); | |
} else if ($scope.videoData.videoFile==null) { | |
$rootScope.showalert("warning", $translate.instant('message.VIDEO_FILE')); | |
} */else { | |
$scope.uploadVideo(); | |
} | |
}; | |
// video link upload | |
$scope.uploadVideo = function () { | |
if (checkConnection()) { | |
//$rootScope.showloader(); | |
var data = $scope.videoData; | |
var params = new Object(); | |
params.key = localStorageService.get('auth_key'), | |
params.uid = localStorageService.get('userId'), | |
params.category_id = data.videoCategory.value, | |
params.title = data.title, | |
params.description = data.description, | |
params.path = data.path, | |
params.tags = data.tags, | |
params.sharePrivacy = data.sharePrivacy, | |
params.location = JSON.stringify(localStorageService.get("address")), | |
$rootScope.showloader(); | |
easysocialService.videolinkupload($scope.videoData).then(function (data) { | |
if (data.success) { | |
$rootScope.showalert("success", data.message); | |
$route.reload(); | |
$location.path(pathConstant.SOCIAL_VIDEOLIST_VIEW_PATH); | |
} else { | |
$rootScope.showalert("error", $translate.instant('message.VIDEO_UPLOAD_FAILED')); | |
$rootScope.hideloader(); | |
} | |
}); | |
} | |
}; | |
// video upload success | |
$scope.newVideosuccess = function (r) { | |
var temp = JSON.parse(r.response); | |
if (temp.status == true || temp.status == "true") { | |
$rootScope.hideloader(); | |
$rootScope.showalert("success", temp.message); | |
//Redirect to video list | |
$location.path(pathConstant.SOCIAL_VIDEOLIST_VIEW_PATH); | |
} else { | |
$rootScope.hideloader(); | |
$rootScope.showalert("error", temp.message); | |
} | |
}; | |
// video upload failure | |
$scope.newVideofail = function (error) { | |
$rootScope.hideloader(); | |
$rootScope.showalert("error", $translate.instant('message.VIDEO_CREATE_ERROR')); | |
}; | |
// view details of particular video | |
$scope.viewVideoDetail = function (id,title,user,category_name,created,description,duration,path,category_id,featured,videoHtml,user_id,admin) { | |
if (id) { | |
localStorageService.set("videoid", id); | |
var loggeduser=localStorageService.get("username"); | |
$rootScope.videoDetails={ | |
id : id, | |
title : title, | |
user : user, | |
category_name : category_name, | |
created : created, | |
description : description, | |
duration : duration, | |
path : path, | |
category_id : category_id, | |
featured : featured, | |
videoHtml : videoHtml, | |
user_id : user_id, | |
loggeduser: loggeduser, | |
isAdmin: admin | |
} | |
} | |
easysocialService.gettaglist(id,user_id).then(function (data) { | |
if (!data.code) { | |
$rootScope.tagdata = data; | |
} | |
}); | |
$location.path(pathConstant.SOCIAL_VIDEODETAIL_VIEW_PATH); | |
}; | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
break; | |
} | |
// Method to send friend request | |
$scope.friendRequest = function (element) { | |
var user_id = element.profileData.id; | |
if (element.profileData.approval_pending) { | |
navigator.notification.confirm($translate.instant('message.CANCEL_FRIEND_REQUEST'), function (result) { | |
if (result == 2) { | |
//#49363 in tracker issue solve. | |
//element.profileData.approval_pending = !element.profileData.approval_pending; | |
easysocialService.removefriend(user_id).then(function (data) { | |
if (data.status) { | |
$rootScope.showalert("success", $translate.instant('message.CANCEL_FRIEND_SUCCESS')); | |
//$scope.showFriends(); | |
$route.reload(); | |
} else { | |
//element.profileData.approval_pending = !element.profileData.approval_pending; | |
} | |
}); | |
return false; | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
return false; | |
} else { | |
//element.profileData.approval_pending = !element.profileData.approval_pending; | |
easysocialService.addfriend(user_id).then(function (data) { | |
if (data.status) { | |
$rootScope.showalert("success", $translate.instant('message.SENT_FRIEND_REQUEST')); | |
//$scope.showFriends(); | |
$route.reload(); | |
} else { | |
//element.profileData.approval_pending = !element.profileData.approval_pending; | |
} | |
}); | |
} | |
}; | |
// Method to remove user from friend's list | |
$scope.unFriendUser = function (element) { | |
var user_id = element.profileData.id; | |
//if (element.profileData.isFriend) { | |
$route.reload(); | |
navigator.notification.confirm($translate.instant('message.UNFRIEND_USER') + element.profileData.username + " ?", function (result) { | |
if (result == 2) { | |
element.profileData.isfriend = !element.profileData.isfriend; | |
easysocialService.removefriend(user_id).then(function (data) { | |
if (data.status) { | |
$rootScope.showalert("success", $translate.instant('message.UNFRIEND_USER_SUCCESS') + element.profileData.username); | |
//$scope.showFriends(); | |
$route.reload(); | |
} else { | |
element.profileData.isfriend = !element.profileData.isfriend; | |
} | |
}); | |
return false; | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
return false; | |
// } | |
}; | |
//Method Accept and reject friend request | |
$scope.acceptFriend = function (element, flag) { | |
var user_id = element.profileData.id; | |
var messageCanel = ""; | |
if (flag == 'reject' || flag == 'cancelrequest') { | |
if (flag == 'cancelrequest') { | |
messageCanel = $translate.instant('message.CANCEL_FRIEND_REQUEST'); | |
} else { | |
messageCanel = $translate.instant('message.REJECT_FRIEND_REQUEST'); | |
} | |
//Name show + element.profileData.username + " ?" | |
navigator.notification.confirm(messageCanel, function (result) { | |
if (result == 2) { | |
easysocialService.acceptRejectFriend(user_id, flag).then(function (data) { | |
if (data) { | |
if (flag == 'reject') { | |
//$rootScope.showalert("success", $translate.instant('message.REJECT_FRIEND_SUCCESS1') + element.profileData.username + $translate.instant('message.REJECT_FRIEND_SUCCESS')); | |
$rootScope.showalert("success", $translate.instant('message.REJECT_FRIEND_SUCCESS')); | |
} else if (flag == 'cancelrequest') { | |
$rootScope.showalert("success", $translate.instant('message.CANCEL_FRIEND_SUCCESS1') + element.profileData.username + $translate.instant('message.CANCEL_FRIEND_SUCCESS2')); | |
} | |
//$scope.showFriends(); | |
$route.reload(); | |
} else { | |
if (flag == 'reject') { | |
$rootScope.showalert("error", $translate.instant('message.REJECT_FRIEND_FAILED')); | |
} else if (flag == 'cancelrequest') { | |
$rootScope.showalert("error", $translate.instant('message.CANCEL_FRIEND_FAILED')); | |
} | |
element.profileData.isfriend = !element.profileData.isfriend; | |
//$rootScope.showalert("error", data.message); | |
} | |
}); | |
return false; | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
} else if (flag == 'accept') { | |
easysocialService.acceptRejectFriend(user_id, flag).then(function (data) { | |
if (data) { | |
if (data.status) { | |
//$rootScope.showalert("success", message.APPROVE_SUCCESS); | |
$rootScope.showalert("success", data.message); | |
} else { | |
$rootScope.showalert("error", data.message); | |
} | |
$route.reload(); | |
//$scope.showFriends(); | |
} else { | |
$rootScope.showalert("error", data.message); | |
element.profileData.isfriend = !element.profileData.isfriend; | |
} | |
}); | |
} | |
} | |
// To search other registered user's on site | |
$rootScope.search_people = function (searchtxt) { | |
var searchName = ""; | |
localStorageService.set("startLimit", 0); | |
if (searchtxt) | |
searchName = searchtxt; | |
else | |
searchName = $scope.people.search; | |
if (searchName) { | |
$rootScope.friends = ""; | |
$rootScope.showloader(); | |
easysocialService.search_people(searchName).then(function (data) { | |
if (!data.code) { | |
if (data.user == 0) { | |
$rootScope.friends = '0'; | |
} else { | |
$rootScope.friends = data.user; | |
if (data.data_status) { | |
//Load more as per the total count | |
if ($rootScope.friends.length % easysocial_count.FRIENDS_LIMIT == 0 && $rootScope.friends.length > 0) { | |
$rootScope.friendsLoadMore = true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
//$rootScope.friendsLoadMore = parseInt(parseInt(localStorageService.get("startLimit")) + parseInt(easysocial_count.FRIENDS_LIMIT)); | |
//$rootScope.friendsLoadMore = $rootScope.friendsLoadMore <= 0 ? false : true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
} | |
} | |
$rootScope.title = $translate.instant('label.SEARCH_RESULT'); | |
$rootScope.hideloader(); | |
}); | |
// To load more data list | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.leaderboard_pagination_limit); | |
easysocialService.search_people(searchName).then(function (data) { | |
if (data.user.status) { | |
$rootScope.friends = $rootScope.friends.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
} | |
}; | |
// To search group on site | |
$scope.search_group = function (searchtxt) { | |
var searchName = ""; | |
localStorageService.set("startLimit", 0); | |
if (searchtxt) | |
searchName = searchtxt; | |
else | |
searchName = $scope.people.search; | |
if (searchName) { | |
$scope.groups = ""; | |
$rootScope.showloader(); | |
easysocialService.search_people(searchName).then(function (data) { | |
if (typeof data.group.status != undefined && (data.group.status == false || data.group.status == 'false')) | |
$scope.group_message = data.group.message; | |
else | |
{ | |
$scope.groups = data.group; | |
if (data.data_status) { | |
//Load more as per the total count | |
if ($scope.groups.length % easysocial_count.FRIENDS_LIMIT == 0 && $scope.groups.length > 0) { | |
$rootScope.friendsLoadMore = true; | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
} else { | |
$rootScope.friendsLoadMore = false; | |
} | |
} | |
$rootScope.title = $translate.instant('label.SEARCH_RESULT'); | |
$rootScope.hideloader(); | |
}); | |
// To load more data list | |
$scope.loadMore = function (callback) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startLimit", parseInt(localStorageService.get("startLimit")) + easysocial_count.leaderboard_pagination_limit); | |
easysocialService.search_people(searchName).then(function (data) { | |
if (data.group.status) { | |
$scope.groups = $scope.groups.concat(data); | |
if (callback) { | |
callback(); | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.loadMore($scope.ESCallLoadMore); | |
} | |
}; | |
$scope.socialShare = function (items) { | |
if (device.platform == "iOS") { | |
//window.plugins.socialsharing.share(blogTitle, blogTitle, blogImage, items.share_url); | |
window.plugins.socialsharing.share(null, null, null, items.share_url); | |
} else if (device.platform == "Android") { | |
window.plugins.socialsharing.share(null, null, null, items.share_url); | |
} | |
}; | |
// To like the stream post | |
$scope.likeStreamPost = function (element, className, done) { | |
if (checkConnection()) { | |
if (element.items.likes.hasLiked) | |
element.items.likes.total = element.items.likes.total - 1; | |
else | |
element.items.likes.total = element.items.likes.total + 1; | |
element.items.likes.hasLiked = !element.items.likes.hasLiked; | |
easysocialService.likepost(element.items.likes).then(function (data) { | |
if (!data.code) { | |
if (data.status) { | |
} else { | |
$rootScope.showalert("error", $translate.instant('message.LIKE_FAIL')); | |
element.items.likes.hasLiked = !element.items.likes.hasLiked; | |
if (element.items.likes.hasLiked) { | |
element.items.likes.total = element.items.likes.total + 1; | |
} else { | |
element.items.likes.total = element.items.likes.total - 1; | |
} | |
} | |
} | |
}); | |
} | |
}; | |
// To load comments for stream post | |
$scope.commentStreamPost = function (element, className, done) { | |
if (checkConnection()) { | |
$rootScope.toggle('comment_dialog', 'on'); | |
$scope.loaderBtn = true; | |
$scope.comments = ""; | |
$scope.comments.commentbox = ""; | |
$rootScope.showloader(); | |
localStorageService.set("toggle", "comment_dialog"); | |
localStorageService.set("startComment", "0"); | |
localStorageService.set("limitIs", easysocial_count.comments_limit); | |
$scope.comment_object = element.items.comments.base_obj; | |
$scope.comment_object["comment_element"] = element.items.comment_element; | |
easysocialService.getcomments($scope.comment_object).then(function (data) { | |
if (!data.code) { | |
$scope.comments = data.data.data; | |
if (data.data.total > 0) { | |
if ($scope.comments.length == data.data.total) { | |
$scope.loaderBtn = false; | |
} | |
} else { | |
$rootScope.hideloader(); | |
} | |
} | |
// To load more comments | |
$scope.loadMoreComments = function () { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
localStorageService.set("startComment", parseInt(localStorageService.get("startComment")) + parseInt(easysocial_count.comments_limit)); | |
easysocialService.getcomments($scope.comment_object).then(function (data) { | |
if (!data.code) { | |
if (typeof data.data.data == 'undefined' || data.data.data.length == 0) { | |
$scope.loaderBtn = false; | |
localStorageService.set("startComment", parseInt(localStorageService.get("startComment")) - parseInt(easysocial_count.comments_limit)); | |
} else { | |
$scope.comments = $scope.comments.concat(data.data.data); | |
if (parseInt($scope.comments.length) == parseInt(data.data.total)) { | |
$scope.loaderBtn = false; | |
} | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$rootScope.hideloader(); | |
}); | |
} | |
// To comment on stream post from comment dialog | |
$scope.postComment = function () { | |
if ($scope.comments.commentbox) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
easysocialService.postcomment($scope.comment_object, $scope.comments.commentbox).then(function (data) { | |
if (!data.code) { | |
if (data.status) { | |
$rootScope.showalert("success", $translate.instant('message.COMMENT_SUCCESS')); | |
element.items.comments.total = parseInt(element.items.comments.total) + 1; | |
} else | |
$rootScope.showalert("warning", $translate.instant('message.COMMENT_FAIL')); | |
} | |
$rootScope.hideloader(); | |
$scope.toggleAction("comment_dialog"); | |
}); | |
} | |
} else { | |
$rootScope.hideloader(); | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_COMMENT')); | |
} | |
}; | |
}; | |
$scope.postSharesuccess = function () { | |
$rootScope.hideloader(); | |
$rootScope.showalert("success", $translate.instant('message.SHARE_SUCCESS')); | |
$scope.share_photo = ""; | |
$scope.share_video = ""; | |
$scope.toggleAction("share_dialog"); | |
$scope.refresh(); | |
} | |
$scope.postSharefail = function () { | |
$rootScope.hideloader(); | |
$rootScope.showalert("error", $translate.instant('message.SHARE_FAIL')); | |
$scope.share_photo = ""; | |
$scope.share_video = ""; | |
$scope.toggleAction("share_dialog"); | |
$scope.refresh(); | |
} | |
$scope.newGroupsuccess = function (r) { | |
$rootScope.hideloader(); | |
$rootScope.showalert("success", $translate.instant('message.GROUP_CREATED')); | |
$scope.saveGroup = true; | |
var temp = JSON.parse(r.response); | |
//$scope.viewGroupDetail(temp.id); | |
$route.reload(); | |
} | |
$scope.newGroupfail = function () { | |
$rootScope.hideloader(); | |
$rootScope.showalert("error", $translate.instant('message.GROUP_CREATED_FAIL')); | |
$scope.share_photo = ""; | |
$scope.refresh(); | |
} | |
$scope.newAlbumsuccess = function (r) { | |
var temp = JSON.parse(r.response); | |
//$rootScope.showalert("success", message.PHOTOS_ADD_SUCCESS); | |
$rootScope.photosCountTemp++; | |
$scope.albumPhotosView(temp.title, temp.id); | |
$scope.addPhotoDiv = false; | |
} | |
$scope.newAlbumfail = function (error) { | |
$rootScope.hideloader(); | |
$rootScope.showalert("error", $translate.instant('message.PHOTO_ADD_FAIL')); | |
} | |
$scope.newAlbumDirSuccess = function (r) { | |
var temp = JSON.parse(r.response); | |
if (temp.id) { | |
$rootScope.showalert("success", $translate.instant('message.ALBUM_CREATED')); | |
$scope.toggleAction('newalbum_dialog'); | |
$scope.showAlbumPhotos(); | |
$rootScope.photosCountTemp = 1; | |
$scope.albumPhotosView(temp.title, temp.id); | |
}else{ | |
$rootScope.hideloader(); | |
//alert(JSON.stringify(temp)); | |
$rootScope.showalert("error", temp.message); | |
} | |
} | |
$scope.uploadAlbumImages = function () { | |
if ($scope.newAlbumPhotos.length == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.ADD_PHOTOS_WARNING')); | |
} else { | |
$rootScope.uploadAlbumImagesInprogress = true; | |
$rootScope.showloader(); | |
//Image Pointer initial set zero | |
$scope.point = 0; | |
for (i = 0; i < $scope.newAlbumPhotos.length; i++) { | |
$scope.uploadAlbumImage(i); | |
} | |
} | |
} | |
$scope.uploadAlbumImage = function (i) { | |
$scope.point = i; | |
var uId = ''; | |
var type = ''; | |
if (localStorageService.get("albumEventType") == "event") { | |
uId = localStorageService.get("eventid"); | |
type = 'event'; | |
} else if (localStorageService.get("albumEventType") == "group") { | |
uId = localStorageService.get("groupid"); | |
type = 'group'; | |
} else { | |
uId = localStorageService.get('userid'); | |
type = 'user'; | |
} | |
var options = new FileUploadOptions(); | |
options.fileKey = "file"; | |
options.fileName = $scope.newAlbumPhotos[i].path.substr($scope.newAlbumPhotos[i].path.lastIndexOf('/') + 1); | |
options.mimeType = "image/jpeg"; | |
var params = new Object(); | |
params.key = localStorageService.get('auth_key'), | |
params.album_id = $scope.albumId, | |
params.userid = uId, | |
params.type = type, | |
options.params = params; | |
options.chunkedMode = false; | |
var objFtFileTransfer = new FileTransfer(); | |
//$rootScope.ft = ft; | |
objFtFileTransfer.onprogress = function (progressEvent) { | |
if (progressEvent.lengthComputable) { | |
var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100); | |
$scope.myCurrent = perc + "%"; | |
$scope.$apply(function () { | |
$scope.newAlbumPhotos[i].progress = perc + "%"; | |
}); | |
} else { | |
if ($scope.newAlbumPhotos[i].progress == "") { | |
$scope.newAlbumPhotos[i].progress = "50%"; | |
} else { | |
$scope.newAlbumPhotos[i].progress += "50%"; | |
} | |
} | |
}; | |
objFtFileTransfer.upload($scope.newAlbumPhotos[i].path, localStorageService.get('url') + "/index.php?option=com_api&app=easysocial&resource=photoadd&format=raw", $scope.newAlbumsuccess, $scope.newAlbumfail, options); | |
} | |
//Vivek Function | |
$scope.addUrl = function (link) { | |
$scope.link = ""; | |
$scope.link = link; | |
if ($scope.link != null && $scope.link != 'undefined' && $scope.link != "") { | |
$scope.message = $scope.message + " " + link; | |
} else { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_LINK')); | |
} | |
} | |
//add tags for video | |
$scope.insertTag = function () { | |
if($scope.tags == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRED_TAG_PEOPLES')); | |
$rootScope.hideloader(); | |
} else { | |
if ($scope.tags.length != 0) { | |
$rootScope.showloader(); | |
localStorageService.set("friends_tags", $scope.tags); | |
} | |
easysocialService.addfriendstag($scope.tags).then(function (data) { | |
$rootScope.tagdata = data; | |
if (!data.code) { | |
if (!data.status) | |
$rootScope.showalert("success", $translate.instant('message.ADD_VIDEO_TAG_SUCCESS')); | |
else | |
$rootScope.showalert("error", $translate.instant('message.ADD_VIDEO_TAG_FAILED')); | |
$rootScope.hideloader(); | |
} | |
$scope.refresh(); | |
}); | |
} | |
} | |
//remove tags for video | |
$scope.removeTag = function (id) { | |
easysocialService.removefriendstag(id).then(function (data) { | |
$rootScope.tagdata = data; | |
if (!data.code) { | |
if (!data.status) | |
$scope.showalert("success", $translate.instant('message.REMOVE_VIDEO_TAG_SUCCESS')); | |
else | |
$rootScope.showalert("error", $translate.instant('message.REMOVE_VIDEO_TAG_FAILED')); | |
$rootScope.hideloader(); | |
} | |
$scope.refresh(); | |
}); | |
} | |
// Share privacy Template | |
$scope.sharePrivacyTemplate = [{ | |
name: $translate.instant('label.SHARE_PRIVACY_EVERYONE'), | |
value: 'public' | |
}, { | |
name: $translate.instant('label.SHARE_PRIVACY_REGISTERED_USERS'), | |
value: 'member' | |
}, { | |
name: $translate.instant('label.SHARE_PRIVACY_MY_FRIENDS'), | |
value: 'friend' | |
}, { | |
name: $translate.instant('label.SHARE_PRIVACY_ONLY_ME'), | |
value: 'only_me' | |
}]; | |
$scope.sharePrivacy = "public"; //default selected | |
// To share some text from share dialog | |
$scope.postShare = function (privacyType) { | |
/*Type and Hash Tag Changes*/ | |
$scope.share.sharebox = $scope.message; | |
var cover = localStorageService.get("coverImagepath"); | |
/* Clear the tags local storage */ | |
var cover = localStorageService.get("coverImagepath"); | |
if ($scope.share.sharebox || cover) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
var res = $scope.share.sharebox.match(/(#\w+)/); | |
var res1 = $scope.link; | |
if (res != null) { | |
localStorageService.set("typeshare", "hashtag"); | |
if ($scope.tags.length != 0) { | |
localStorageService.set("friends_tags", $scope.tags); | |
} | |
} else if (res1 != null && res1 != 'undefined') { | |
localStorageService.set("typeshare", "story"); | |
} else { | |
localStorageService.set("typeshare", "story"); | |
if ($scope.tags.length == 0) { | |
localStorageService.set("friends_tags", ""); | |
} else { | |
localStorageService.set("typeshare", "story"); | |
localStorageService.set("friends_tags", $scope.tags); | |
} | |
} | |
easysocialService.postshare($scope.share.sharebox, privacyType).then(function (data) { | |
if (!data.code) { | |
if (data.status) | |
$rootScope.showalert("success", data.message); | |
else | |
$rootScope.showalert("error", data.message); | |
//$rootScope.showalert(message.SHARE_SUCCESS); | |
//$rootScope.showalert(message.SHARE_FAIL); | |
$rootScope.hideloader(); | |
} | |
$scope.toggleAction("share_dialog"); | |
$scope.refresh(); | |
}); | |
} | |
} else { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_SHARE_TEXT')); | |
$rootScope.hideloader(); | |
} | |
}; | |
//Added by pratiksha : go to back from report view to group detail view | |
$scope.viewGroupDet = function () { | |
if ($rootScope.stream_id) { | |
localStorageService.set("groupid", $rootScope.stream_id); | |
} | |
$location.path(pathConstant.SOCIAL_GROUPDETAIL_VIEW_PATH); | |
}; | |
$scope.viewEventDet = function () { | |
if ($rootScope.stream_id) { | |
localStorageService.set("eventid", $rootScope.stream_id); | |
$rootScope.EventID = $rootScope.stream_id; | |
} | |
$location.path(pathConstant.SOCIAL_EVENTDETAIL_VIEW_PATH); | |
}; | |
//go to group album | |
$scope.groupAlbum1 = function () { | |
localStorageService.set("albumEventType", "group"); | |
$scope.type = 'group'; | |
$rootScope.gno = 1; | |
easysocialService.getAlbumsList($rootScope.album_id, $scope.type); | |
} | |
// Group Member list | |
$scope.viewGroupMember = function (id, name, isowner, ismember) { | |
$rootScope.showloader(); | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
if (id) | |
localStorageService.set("groupid", id); | |
localStorageService.set("groupowner", isowner); | |
$rootScope.title = $translate.instant('titleConstant.SOCIAL_GROUPMEMBER'); | |
$rootScope.groupTitleMember = name; | |
$rootScope.groupIsOwnerMember = ismember; | |
$rootScope.groupIsOwner = isowner; | |
$rootScope.showloader(); | |
$rootScope.friends = ""; | |
$scope.loaderBtn = true; | |
$location.path(pathConstant.SOCIAL_GROUPMEMBER_VIEW_PATH); | |
} | |
} | |
}; | |
//Group Member requst of reject, cancel and withdraw | |
$scope.groupMemberRequest = function (request, id, username,type) { | |
var rejectMessage = ""; | |
if (request == 'reject' || request == 'cancel' || request == 'withdraw') { | |
if (request == 'reject') { | |
rejectMessage = $translate.instant('message.GROUP_MEMBER_REJECT_REQUEST_1') + username + $translate.instant('message.GROUP_MEMBER_REJECT_REQUEST_2') + type + '?'; | |
} else if (request == 'withdraw') { | |
//username take as group name for withdraw only. | |
$rootScope.groupTitleMember = username; | |
id = localStorageService.get("userid"); | |
rejectMessage = $translate.instant('message.GROUP_WITHDRAW_REQUEST') + $rootScope.groupTitleMember + '?'; | |
} else { | |
rejectMessage = $translate.instant('message.GROUP_MEMBER_CANCEL_REQUEST_1') + username + $translate.instant('message.GROUP_MEMBER_CANCEL_REQUEST_2') + type + '?'; | |
request = 'reject'; | |
} | |
navigator.notification.confirm(rejectMessage, function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.groupMemberRequest(request, id, type).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
$scope.refresh(); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
} else { | |
$rootScope.showloader(); | |
easysocialService.groupMemberRequest(request, id, type).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", data.message); | |
$scope.refresh(); | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
}; | |
$scope.resetShareBox = function (option) { | |
$scope.smessage = false; | |
$scope.photoshare = false; | |
$scope.addlink = false; | |
$scope.videoshare = false; | |
switch (option) | |
{ | |
case 'message': | |
$scope.smessage = true; | |
break; | |
case 'addlink': | |
$scope.addlink = true; | |
break; | |
case 'photoshare': | |
$scope.photoshare = true; | |
break; | |
case 'videoshare': | |
$scope.videoshare = true; | |
break; | |
} | |
}; | |
// Called when share dialog opens | |
$scope.openShareDialog = function () { | |
localStorageService.set("toggle", "share_dialog"); | |
localStorageService.set("coverImagepath", ""); | |
$rootScope.toggle('share_dialog', 'on'); | |
$scope.share.sharebox = ""; | |
$scope.tags = ""; | |
$scope.message = ""; | |
$scope.photoshare = false; | |
localStorageService.set("friends_tags", ""); | |
$scope.mentionLabel = ""; | |
$scope.addFriendFlag = false; | |
$scope.share_photo = ""; | |
$scope.videoshare = false; | |
localStorageService.set("friends_tags", ""); | |
$scope.mentionLabel = ""; | |
$scope.addFriendFlag = false; | |
$scope.share_video = ""; | |
}; | |
// Called when share dialog option selected | |
//need for reset/hightlight share option | |
$scope.resetShareBox = function (option) { | |
$scope.smessage = false; | |
$scope.photoshare = false; | |
$scope.addlink = false; | |
$scope.videoshare = false; | |
switch (option) | |
{ | |
case 'message': | |
$scope.smessage = true; | |
break; | |
case 'addlink': | |
$scope.addlink = true; | |
break; | |
case 'photoshare': | |
$scope.photoshare = true; | |
break; | |
case 'videoshare': | |
$scope.videoshare = true; | |
break; | |
} | |
}; | |
//need to add url to textArea | |
$scope.url = function (option) { | |
$scope.message = $scope.message + " " + option; | |
} | |
// To toggle any angular element | |
$scope.toggleAction = function (element) { | |
localStorageService.set("toggle", ""); | |
$rootScope.toggle(element); | |
}; | |
// To show header with textbox for share | |
$scope.showTo = function (title) { | |
return title == $translate.instant('titleConstant.SOCIAL_NEWSFEED'); | |
}; | |
// Set the user's name in sidebar | |
$scope.getCurrentUsername = function () { | |
return localStorageService.get("currentuname"); | |
}; | |
// To view logged in user's profile | |
$scope.viewMyProfile = function () { | |
if (checkConnection()) { | |
$scope.setDefaultUser(); | |
$location.path(pathConstant.SOCIAL_VIEWPROFILE_VIEW_PATH); | |
} | |
}; | |
$scope.attendEvent = function (element, state) { | |
//Previous object saved in temp if failed service. | |
$scope.tempElement = { | |
isAttending: element.isAttending, | |
isMaybe: element.isMaybe, | |
isNotAttending: element.isNotAttending, | |
isPendingMember: element.isPendingMember, | |
allownotgoingguest: element.params.allownotgoingguest, | |
}; | |
//Toggle the value | |
element.isAttending = (!element.isAttending && state == 'going') ? true : false; | |
element.isMaybe = (!element.isMaybe && state == 'maybe') ? true : false; | |
element.isNotAttending = (!element.isNotAttending && state == 'notgoing') ? true : false; | |
element.isPendingMember = (!element.isPendingMember && state == 'request') ? true : false; | |
easysocialService.attendEvent(element.id, state).then(function (data) { | |
if (data.status) { | |
if (state == 'going' || state == 'maybe') { | |
//Checking the event already in calendar. | |
window.plugins.calendar.findEvent(element.title, | |
element.location, element.description, | |
startDate, endDate, $scope.findSuccess, error); | |
} else if (state == 'notgoing') { | |
window.plugins.calendar.deleteEvent(element.title, | |
element.location, element.description, | |
startDate, endDate, success, error); | |
} | |
} else { | |
//Set as the previous state | |
element.isAttending = $scope.tempElement.isAttending; | |
element.isMaybe = $scope.tempElement.isMaybe; | |
element.isNotAttending = $scope.tempElement.isNotAttending; | |
element.isPendingMember = $scope.tempElement.isPendingMember; | |
element.params.allownotgoingguest = $scope.tempElement.allownotgoingguest; | |
} | |
}); | |
// Platform set | |
$scope.devicePlatform = device.platform; | |
var startDate = new Date(element.details.start); | |
var endDate = new Date(element.details.end); | |
if (element.details.end == "0000-00-00 00:00:00") { | |
tempEndDate = startDate; | |
tempEndDate.setDate(tempEndDate.getDate() + 1); // Added one day | |
} else if (startDate.getTime() == endDate.getTime()) { | |
tempEndDate = startDate; | |
tempEndDate.setDate(tempEndDate.getDate() + 1); // Added one day | |
} else { | |
tempEndDate = new Date(element.details.end) | |
} | |
endDate = tempEndDate; | |
//For the device dependent code | |
if (device.platform == "iOS") { | |
//Format of iOS code required | |
//new Date(year, month, day, hours, minutes, seconds, milliseconds) | |
startDate = element.details.ios_start; | |
endDate = element.details.ios_end; | |
startDate = new Date(startDate.year, startDate.month - 1, startDate.day, startDate.hour, startDate.minutes, startDate.seconds, 0, 0); | |
endDate = new Date(endDate.year, endDate.month - 1, endDate.day, endDate.hour, endDate.minutes, endDate.seconds, 0, 0); | |
} else if (device.platform == "Android") { | |
startDate = new Date(element.details.start); | |
endDate = tempEndDate; | |
} | |
var success = function (message) { | |
//alert("Success: " + JSON.stringify(message)); | |
}; | |
var error = function (message) { | |
//alert("Error: " + message); | |
$rootScope.showalert("error", $translate.instant('message.EVENT_CALENDAR_ERROR')); | |
}; | |
$scope.isFind = false; | |
//Event already in calendar success function | |
$scope.findSuccess = function (message) { | |
//Event is not find in calendar and create new event | |
if (message.length == 0) { | |
$scope.isFind = false; | |
window.plugins.calendar.createEvent(element.title, | |
element.location, element.description, | |
startDate, endDate, success, error); | |
} else { | |
//Event found in calendar then delete old event and create new event | |
$scope.isFind = true; | |
$scope.findEvent = message; | |
if (device.platform == "iOS") { | |
dStartDate = element.details.ios_start; | |
dEndDate = element.details.ios_end; | |
dStartDate = new Date(dStartDate.year, dStartDate.month - 1, dStartDate.day, dStartDate.hour, dStartDate.minutes, dStartDate.seconds, 0, 0); | |
dEndDate = new Date(dEndDate.year, dEndDate.month - 1, dEndDate.day, dEndDate.hour, dEndDate.minutes, dEndDate.seconds, 0, 0); | |
} else if (device.platform == "Android") { | |
var dStartDate = new Date($scope.findEvent[0].startDate); | |
var dEndDate = new Date($scope.findEvent[0].endDate); | |
} | |
window.plugins.calendar.deleteEvent($scope.findEvent[0].title, | |
$scope.findEvent[0].location, | |
$scope.findEvent[0].message, | |
dStartDate, dEndDate, | |
success, error); | |
window.plugins.calendar.createEvent(element.title, | |
element.location, element.description, | |
startDate, endDate, success, error); | |
} | |
}; | |
$scope.findError = function (message) { | |
$scope.isFind = false; | |
}; | |
}; | |
// To search other peoples on network | |
$scope.search_social_people = function () { | |
if (checkConnection()) { | |
if ($scope.people.search) { | |
//localStorageService.set("friendlist", ""); | |
localStorageService.set("friendlistFilter", "search"); | |
$rootScope.friendFilter = localStorageService.get("friendlistFilter"); | |
$rootScope.searchPeopleTemp = $scope.people.search; | |
$rootScope.tabPos = "positionSearchRight"; | |
$route.reload(); | |
//$location.path(pathConstant.SOCIAL_FRIENDS_VIEW_PATH); | |
//$rootScope.search_people($scope.people.search); | |
} | |
} | |
}; | |
/*Group list filter and friend list filter */ | |
$scope.listfilter = function (_path, _filter, _mainfilter) { | |
if (checkConnection()) { | |
if (localStorageService.get("auth_key")) { | |
if (_filter) { | |
switch (_mainfilter) { | |
case 'grouplist': | |
localStorageService.set("grouplistFilter", _filter); | |
if (_filter == 'search' || _filter == 'all' || _filter == 'featured') { | |
$rootScope.tabPos = "positionInitial"; | |
} | |
if (_filter == 'mygroups' || _filter == 'invited') { | |
$rootScope.tabPos = "positionRight"; | |
} | |
$route.reload(); | |
break; | |
case 'discussions': | |
localStorageService.set("discussionFilter", _filter); | |
break; | |
case 'friends': | |
localStorageService.set("friendlistFilter", _filter); | |
/* Adding class for set friend filter Position */ | |
if (_filter == 'search' || _filter == 'all' || _filter == 'suggest') { | |
$rootScope.tabPos = "positionInitial"; | |
} | |
if (_filter == 'pending' || _filter == 'request' || _filter == 'invites') { | |
$rootScope.tabPos = "positionRight"; | |
} | |
$route.reload(); | |
break; | |
case 'eventlist': | |
localStorageService.set("eventlistFilter", _filter); | |
localStorageService.set("date", ""); | |
localStorageService.set("startDate", ""); | |
localStorageService.set("endDate", ""); | |
localStorageService.set("startBefore", ""); | |
localStorageService.set("cdate", ""); | |
localStorageService.set("categoryid", ""); | |
break; | |
case 'videolist': | |
localStorageService.set("videolistFilter", _filter); | |
localStorageService.set("sort", ""); | |
localStorageService.set("categoryid", ""); | |
break; | |
case 'events': | |
localStorageService.set("eventguestFilter", _filter); | |
break; | |
} | |
$route.reload(); | |
} | |
$location.path(_path); | |
} else { | |
$rootScope.logoutApp(); | |
} | |
} | |
}; | |
/* Friends swipe left-right function */ | |
var friendFilterArray = ['all', 'suggest', 'pending', 'request', 'invites']; | |
$scope.friendsSwipeTab = function (dir) { | |
var friendFilter = localStorageService.get("friendlistFilter"); | |
var count = friendFilterArray.indexOf(friendFilter); | |
if (checkConnection()) { | |
if (dir == "left") { | |
count = count + 1; | |
} else { | |
count = count - 1; | |
} | |
$scope.listfilter('/easysocial/friends', friendFilterArray[count], 'friends'); | |
} | |
} | |
//v Groups Swipe Left-right Function */ | |
var groupFilterArray = ['all', 'featured', 'mygroups', 'invited']; | |
$scope.swipeTab = function (dir) { | |
var groupFilter = localStorageService.get("grouplistFilter"); | |
var count = groupFilterArray.indexOf(groupFilter); | |
if (checkConnection()) { | |
if (dir == "left") { | |
count = count + 1; | |
} else { | |
count = count - 1; | |
} | |
$scope.listfilter('/easysocial/grouplist', groupFilterArray[count], 'groups'); | |
} | |
} | |
//Event guest swipe | |
var eventguestArrayFilter = ['admins', 'going', 'maybe', 'notgoing']; | |
$scope.guestSwipe = function (dir) { | |
var fcount = localStorageService.get("eventguestFilter"); | |
var count = eventguestArrayFilter.indexOf(fcount); | |
if (checkConnection()) { | |
if (dir == "left") { | |
count = count + 1; | |
} else { | |
count = count - 1; | |
} | |
$scope.listfilter('/easysocial/event', eventguestArrayFilter[count], 'events'); | |
} | |
}; | |
/* Videos swipe left-right function */ | |
var videosFilterArray = ['all', 'featured', 'my']; | |
$scope.videosSwipeTab = function (dir) { | |
var videosFilter = localStorageService.get("videolistFilter"); | |
var count = videosFilterArray.indexOf(videosFilter); | |
if (checkConnection()) { | |
if (dir == "left") { | |
count = count + 1; | |
} else { | |
count = count - 1; | |
} | |
$scope.listfilter('/easysocial/videolist', friendFilterArray[count], 'videos'); | |
} | |
} | |
// To search groups on network | |
$scope.search_social_group = function () { | |
if (checkConnection()) { | |
if ($scope.people.search) { | |
localStorageService.set("grouplistFilter", "search"); | |
$rootScope.groupFilter == 'search'; | |
$rootScope.groupFilter = localStorageService.get("grouplistFilter"); | |
$rootScope.searchPeopleTemp = $scope.people.search; | |
$rootScope.tabPos = "positionSearchRight"; | |
$location.path(pathConstant.SOCIAL_GROUPLIST_VIEW_PATH); | |
$scope.search_group($scope.people.search); | |
// $route.reload(); | |
} | |
} | |
}; | |
// Refresh the page content | |
$scope.refresh = function () { | |
if (checkConnection()) { | |
localStorageService.set("startLimit", 0); | |
$route.reload(); | |
} | |
}; | |
// Show user's profile | |
$scope.viewUserprofile = function (uid) { | |
if (checkConnection()) { | |
$rootScope.showloader(); | |
if (uid) | |
localStorageService.set("currentuid", uid); | |
$location.path(pathConstant.SOCIAL_VIEWPROFILE_VIEW_PATH); | |
$scope.refresh(); | |
} | |
}; | |
// Display the user's friend list | |
$scope.showMyFriends = function () { | |
if (checkConnection()) { | |
//localStorageService.set("friendlist", 1); | |
localStorageService.set("friendlist", ""); | |
localStorageService.set("friendlistFilter", "all"); | |
$location.path(pathConstant.SOCIAL_FRIENDS_VIEW_PATH); | |
} | |
}; | |
// Display the user's group list | |
$scope.showMyGroups = function () { | |
if (checkConnection()) { | |
//localStorageService.set("targetuser", 1); | |
localStorageService.set("grouplist", ""); /* vivek */ | |
localStorageService.set("grouplistFilter", "all"); | |
$location.path(pathConstant.SOCIAL_GROUPLIST_VIEW_PATH); | |
} | |
}; | |
// Set logged in user | |
$scope.setDefaultUser = function () { | |
localStorageService.set("currentuid", localStorageService.get("userid")); | |
}; | |
// Set the newsfeed stream subtitle | |
$scope.getFilterName = function () { | |
var setTitle = ""; | |
var filterIs = localStorageService.get("newsfeedFilter"); | |
if (filterIs == "me") { | |
setTitle = $translate.instant('titleConstant.SOCIAL_ME_FRIENDS'); | |
} else if (filterIs == "everyone") { | |
setTitle = $translate.instant('titleConstant.SOCIAL_EVERYONE'); | |
} else if (filterIs == "following") { | |
setTitle = $translate.instant('titleConstant.SOCIAL_FOLLOWING'); | |
} else if (filterIs == "photos") { | |
setTitle = $translate.instant('titleConstant.SOCIAL_PHOTOS'); | |
} else if (filterIs == "sticky") { | |
setTitle = $translate.instant('titleConstant.SOCIAL_PINNED'); | |
} else if (filterIs == "hashtag") { | |
setTitle = "#" + localStorageService.get("hashtag"); | |
} | |
return setTitle; | |
}; | |
//Bind html convert | |
$scope.to_trusted = function (html_code) { | |
return $sce.trustAsHtml(html_code); | |
$rootScope.hideloader(); | |
}; | |
/* on click content image see in fullscreen */ | |
$scope.openZoom = function (url) { | |
$rootScope.toggle('image_dialog', 'on'); | |
localStorageService.set("toggle", "image_dialog"); | |
//localStorageService.set("imgUrlZoom", url); | |
$scope.zoomImageUrl = url; | |
//$location.path(pathConstant.SOCIAL_PHOTO_ZOOM_VIEW_PATH); | |
}; | |
/* Album Photo zoom in fullscreen */ | |
$scope.openAlbumPhotoZoom = function (image, imageObject, i) { | |
$rootScope.toggle('album_image_dialog', 'on'); | |
localStorageService.set("toggle", "album_image_dialog"); | |
$scope.items = image; | |
$scope.imagePointer = i; | |
$scope.imageObject = imageObject; | |
//$scope.zoomImageUrl = imageObject.image_large; | |
}; | |
$rootScope.getAutoLocation = function () { | |
$scope.isLocationMap = true; | |
navigator.geolocation.getCurrentPosition( | |
function (position) { // success | |
var lat = position.coords.latitude; | |
var long = position.coords.longitude; | |
localStorageService.set("lat", lat); | |
localStorageService.set("long", long); | |
$scope.mapInitialization(); | |
$scope.getLocationDetails(); | |
}, | |
function (error) { //error | |
//localStorageService.set("lat", diginDefaults.GEO_LAT); | |
//localStorageService.set("long", diginDefaults.GEO_LONG); | |
$rootScope.locationError = error.code; | |
if (error.code == "1") { | |
$rootScope.showalert("error", $translate.instant('message.GPS_NOT')); | |
} else if (error.code == "2") { | |
$rootScope.showalert("error", $translate.instant('message.POSITION_UNAVAILABLE')); | |
} else if (error.code == "3") { | |
$rootScope.showalert("error", $translate.instant('message.POSITION_TIMEOUT')); | |
} | |
}, { | |
enableHighAccuracy: true, | |
timeout: 10000 | |
}); | |
}; | |
//Get location details and create object to required in create event. | |
$scope.getLocationDetails = function () { | |
easysocialService.getLocationDetails().then(function (data) { | |
if (data.results.length != '0') { | |
angular.forEach(data.results[0].address_components, function (value, key) { | |
var type = value.types[0]; | |
switch (type) { | |
case 'street_number': | |
$scope.street_number = value.long_name; | |
break; | |
case 'route': | |
$scope.route = value.long_name; | |
break; | |
case 'sublocality_level_2': | |
$scope.sublocality_level_2 = value.long_name; | |
break; | |
case 'sublocality_level_1': | |
$scope.sublocality_level_1 = value.long_name; | |
break; | |
case 'locality': | |
$scope.locality = value.long_name; | |
break; | |
case 'administrative_area_level_2': | |
$scope.administrative_area_level_2 = value.long_name; | |
break; | |
case 'administrative_area_level_1': | |
$scope.administrative_area_level_1 = value.long_name; | |
break; | |
case 'postal_code': | |
$scope.zipcode = value.long_name; | |
break; | |
case 'country': | |
$scope.country = value.long_name; | |
break; | |
default: | |
} | |
}); | |
var lat = localStorageService.get("lat"); | |
var long = localStorageService.get("long"); | |
var locationObj = { | |
address1: null, | |
address2: null, | |
city: null, | |
state: null, | |
zip: $scope.zipcode, | |
country: $scope.country, | |
components: { | |
street_number: $scope.street_number, | |
route: $scope.route, | |
sublocality_level_2: $scope.sublocality_level_2, | |
sublocality_level_1: $scope.sublocality_level_1, | |
locality: $scope.locality, | |
administrative_area_level_2: $scope.administrative_area_level_2, | |
administrative_area_level_1: $scope.administrative_area_level_1, | |
country: $scope.country, | |
postal_code: $scope.zipcode | |
}, | |
address: data.results[0].formatted_address, | |
latitude: lat, | |
longitude: long | |
}; | |
$scope.eventData.elocation = data.results[0].formatted_address; | |
//$scope.location = data.results[0].formatted_address; | |
localStorageService.set("address", locationObj); | |
} | |
}); | |
}; | |
/* Image swipe change left and right direction respective next and previos image */ | |
$scope.swipeImages = function (dir) { | |
if (dir == "left") { | |
if ($scope.imagePointer <= $scope.imageObject.length - 2) { | |
$scope.imagePointer += 1; | |
} | |
} else { | |
if ($scope.imagePointer >= 1) { | |
$scope.imagePointer -= 1; | |
} | |
} | |
$scope.items = $scope.imageObject[$scope.imagePointer]; | |
} | |
/* On Long Press delete photo */ | |
$scope.deletePhoto = function (title, albumId, id, isowner) { | |
if (isowner == true) { | |
navigator.notification.confirm($translate.instant('message.DELETE_PHOTO'), function (result) { | |
if (result == 2) { | |
$rootScope.showloader(); | |
easysocialService.deletephoto(id).then(function (data) { | |
if (!data.code) { | |
$rootScope.showalert("success", $translate.instant('message.PHOTO_DELETED_SUCCESS')); | |
$scope.albumPhotosView(title, albumId); | |
//$location.path(pathConstant.); | |
} else { | |
$rootScope.hideloader(); | |
} | |
}); | |
} | |
}, $translate.instant('message.APP_NAME'), $translate.instant('label.SOCIAL_NAVIGATOR')); | |
} else { | |
$rootScope.showalert("warning", $translate.instant('message.PHOTO_DELETED_WARNING')); | |
} | |
}; | |
//Function user for auto complete Friend List on share and conversation. | |
$scope.loadCountries = function ($query) { | |
var url = localStorageService.get("url"); | |
var userkey = localStorageService.get("auth_key"); | |
var startIs = localStorageService.get("startLimit"); | |
var limitIs = localStorageService.get("limitIs"); | |
var filterVal = $query; | |
return $http.get('' + url + '/?option=com_api&app=easysocial&resource=friend&format=raw&key=' + userkey + '&search=' + filterVal, { | |
cache: true | |
}).then(function (response) { | |
var countries = response.data; | |
return countries.filter(function (country) { | |
//return country.username.toLowerCase().indexOf($query.toLowerCase()) != -1; | |
return country.username.toString().toLowerCase().indexOf($query.toString().toLowerCase()) != -1; | |
}); | |
}); | |
}; | |
//Mention with label show set eg. with Danny and Nadia. | |
$scope.tagsChanged = function () { | |
var length = $scope.tags.length; | |
if (length == 0) { | |
$scope.labelStatus = false; | |
} else { | |
$scope.labelStatus = true; | |
$scope.mentionLabel = "-- With " + $scope.tags[0].username; | |
for (i = 0; i < length - 2; i++) { | |
$scope.mentionLabel = $scope.mentionLabel + ", " + $scope.tags[i + 1].username | |
} | |
if (length - 1 != 0) { | |
$scope.mentionLabel = $scope.mentionLabel + " and " + $scope.tags[length - 1].username | |
} | |
} | |
} | |
//function for report toggle | |
$scope.toggleReport = function (element, id, reportStatus, type, gid) { | |
$rootScope.album_id = gid; | |
$rootScope.reportstatus = reportStatus; | |
$rootScope.type = type; | |
$rootScope.stream_id = id; | |
localStorageService.set("toggle", "report_here"); | |
$rootScope.toggle('report_here', 'on'); | |
} | |
//Report item function | |
$scope.reportItem = function (formdata) { | |
if ($scope.reportitemform.report_description.$invalid) { | |
$rootScope.showalert("warning", $translate.instant('message.REQUIRE_MESSAGE')); | |
} else { | |
$rootScope.showloader(); | |
easysocialService.reportitem(formdata.report_description, $rootScope.stream_id, $rootScope.type).then(function (data) { | |
if (!data.code) { | |
$rootScope.reportstatus = false; | |
$rootScope.showalert("success", data.message); | |
} | |
$rootScope.hideloader(); | |
formdata.report_description = ""; | |
}); | |
} | |
}; | |
// Called when invite dialog opens | |
$scope.openInvite = function () { | |
localStorageService.set("toggle", "invite_dialog"); | |
$rootScope.toggle('invite_dialog', 'on'); | |
$scope.tags = ""; | |
$scope.invited = false; | |
}; | |
//Send Group invitations function | |
$scope.send_invite = function () { | |
$rootScope.showloader(); | |
$scope.invited = false; | |
if ($scope.tags.length == 0) { | |
$rootScope.showalert("warning", $translate.instant('message.FRIEND_INVITE_MESSAGE_ERROR')); | |
$rootScope.hideloader(); | |
} else { | |
$rootScope.showloader(); | |
easysocialService.groupinvite($scope.tags).then(function (data) { | |
if (!data.code) { | |
if (data.status) { | |
$scope.invited = true; | |
var invited_members = '\n'; | |
var not_invited_members = '\n'; | |
for (var i = 0; i < data.invited.length; i++) { | |
invited_members = invited_members.concat(', ' + data.invited[i].toString()); | |
} | |
for (var i = 0; i < data.not_invtited.length; i++) { | |
not_invited_members = not_invited_members.concat(', ' + data.not_invtited[i].toString()); | |
} | |
if ((data.not_invtited.length != 0) && (data.invited.length != 0)) { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_INVITE_SUCCESS') + ' ' + invited_members + '. ' + $translate.instant('message.FRIEND_NON_INVITE_SUCCESS') + ' ' + not_invited_members + ''); | |
} else if ((data.not_invtited.length == 0) && (data.invited.length != 0)) { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_INVITE_SUCCESS') + ' ' + invited_members); | |
} else { | |
$rootScope.showalert("success", $translate.instant('message.FRIEND_INVITE_SUCCESS') + ' ' + invited_members + '. ' + $translate.instant('message.FRIEND_NON_INVITE_SUCCESS') + ' ' + not_invited_members + ''); | |
} | |
} else { | |
$rootScope.showalert("error", $translate.instant('message.FRIEND_INVITE_ERROR')); | |
} | |
} | |
$rootScope.hideloader(); | |
}); | |
} | |
} | |
//get filterid and store in localhost. | |
//solution for menu selection issue | |
function storeFilter(curr_arr) { | |
var filter_arr = $rootScope.marr; | |
if (filter_arr.length == curr_arr.length) { | |
return filter_arr; | |
} else { | |
var x = new Array(); | |
for (var i = 0; i < curr_arr.length; i++) { | |
if (x[curr_arr[i].path]) { | |
x['#' + curr_arr[i].main_filter + '/' + curr_arr[i].menu_name] = curr_arr[i].filterid; | |
} else { | |
//localStorageService.set('filter_arr',x); | |
x['#' + curr_arr[i].path] = curr_arr[i].filterid; | |
} | |
} | |
//localStorageService.set("filter_arr", JSON.stringify(x) ); | |
$rootScope.marr = x; | |
} | |
} | |
$scope.searchTab = function () { | |
$("#gall").removeClass("active"); | |
$("#gfeatured").removeClass("active"); | |
$("#gmygroups").removeClass("active"); | |
$("#ginvited").removeClass("active"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment