AIA.controller("CAController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "pages", "BodyRegions", "BodySystems", "MedicalSpecialties", "DataService",
function ($scope, $window, $rootScope, $compile, $http, log, $location, pages, BodyRegions, BodySystems, MedicalSpecialties, DataService) {
$rootScope.currentActiveModuleTitle = pages[4].name;
$scope.showme = true;
$scope.AnimationData;
$scope.CAAllBodyRegion = [];
$scope.CAAllBodySystem = [];
$scope.CAAllSpeciality = [];
$scope.selectedCAListViewData = [];
$scope.searchCAListViewData = [];
$scope.SelectedCAthumbImage = [];
$scope.SelectedCAImage = [];
$scope.SelectedCASummary = [];
$scope.filterstring = false;
$scope.query = {
selectedbodyregion: null,
selectedbodysystem: null,
selectedspecialty: null,
};
$scope.$on('$viewContentLoaded', function (event) {
// code that will be executed ...
// every time this view is loaded
$scope.CAAllBodyRegion = BodyRegions;
$scope.CAAllBodySystem = BodySystems;
$scope.CAAllSpeciality = MedicalSpecialties;
$scope.scroll();
});
var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
promise.then(
function (result) {
$scope.AnimationData = result;
//$scope.selectedCAListViewData = $scope.AnimationData.root.CAData;
$scope.selectedCAListViewData = new jinqJs()
.from($scope.AnimationData.root.CAData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
console.log($scope.selectedCAListViewData);
$('#grid-view').empty();
angular.forEach($scope.selectedCAListViewData, function (value, key) {
$scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
var $el = $('
'
+ '
'
+ '
![]()
'
+ '
').appendTo('#grid-view');
$compile($el)($scope);
$(".sidebar").mCustomScrollbar({
autoHideScrollbar: true,
//theme:"rounded"
});
});
},
function (error) {
// handle errors here
console.log(' $scope.AnimationData = ' + error.statusText);
}
);
$scope.IsVisible = function () {
$scope.scroll();
}
$scope.showItem = function (id) {
//console.log(id);
$scope.hiderow = true;
if ($scope.filterstring == false) {
var SelectedCAthumbImage = [];
SelectedCAthumbImage = new jinqJs()
.from($scope.selectedCAListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
$scope.SelectedCASummary = SelectedCAthumbImage[0]._Summary;
$scope.SelectedCAId = SelectedCAthumbImage[0]._id;
$scope.SelectedCATitle = SelectedCAthumbImage[0]._Title;
}
else {
if ($scope.searchCAListViewData.length > 0) {
var SelectedCAthumbImage = [];
SelectedCAthumbImage = new jinqJs()
.from($scope.searchCAListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
$scope.SelectedCASummary = SelectedCAthumbImage[0]._Summary;
$scope.SelectedCAId = SelectedCAthumbImage[0]._id;
$scope.SelectedCATitle = SelectedCAthumbImage[0]._Title;
}
}
};
$scope.Reset = function (query) {
query.selectedbodyregion = null;
query.selectedbodysystem = null;
query.selectedspecialty = null;
$scope.filterstring = false;
while ($scope.searchCAListViewData.length) {
$scope.searchCAListViewData.pop();
}
$('#grid-view').empty();
angular.forEach($scope.selectedCAListViewData, function (value, key) {
$scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
var $el = $(''
+ '
'
+ '
![]()
'
+ '
').appendTo('#grid-view');
$compile($el)($scope);
$(".sidebar").mCustomScrollbar({
autoHideScrollbar: true,
//theme:"rounded"
});
});
}
$scope.ApplySearch = function (query) {
$scope.filterstring = true;
while ($scope.searchCAListViewData.length) {
$scope.searchCAListViewData.pop();
}
$('#grid-view').empty();
filtercount = 0;
if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
filtercount = filtercount + 1;
}
if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
filtercount = filtercount + 1;
}
if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
filtercount = filtercount + 1;
}
angular.forEach($scope.selectedCAListViewData, function (value, key) {
var selectimg = true;
var count = 0;
if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null) {
var posbodyregion = value._BodyRegion.indexOf((query.selectedbodyregion.trim()));
if (posbodyregion > -1) {
selectimg = true;
count = count + 1;
}
else {
selectimg = false;
count = count - 1;
}
}
if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null) {
var posbodysystem = value._BodySystem.indexOf(query.selectedbodysystem);
if (posbodysystem > -1) {
count = count + 1;
selectimg = true;
} else {
selectimg = false;
count = count - 1;
}
}
if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) {
var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
if (posspeciality > -1) {
count = count + 1;
selectimg = true;
} else {
selectimg = false;
count = count - 1;
}
}
if (selectimg === true && count >= filtercount) {
$scope.imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
var $el = $(''
+ '
'
+ '
![]()
'
+ '
').appendTo('#grid-view');
$compile($el)($scope);
$(".sidebar").mCustomScrollbar({
autoHideScrollbar: true,
//theme:"rounded"
});
$scope.searchCAListViewData.push(
{
"_id": value._id,
"_ImageId": value._ImageId,
"_Title": value._Title,
"_Video": value._Video,
"_ThumbnailImage": value._ThumbnailImage,
"_BodySystem": value._BodySystem,
"_BodyRegion": value._BodyRegion,
"_MedicalSpecialty": value._MedicalSpecialty,
"_Summary": value._Summary,
"_LowerSummary": value._LowerSummary
});
}
});
//Show Error Message in case of gridview if no data is found
if ($scope.searchCAListViewData.length == 0) {
var $el = $('No animation found for the selected search criteria!
').appendTo('#grid-view');
$compile($el)($scope);
}
}
$scope.scroll = function () {
$("html,body").scrollTop(0);
}
$scope.openView = function ($event) {
$rootScope.currentBodyViewId = $event.currentTarget.id;
if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
var CITitle = [];
CITitle = new jinqJs()
.from($scope.selectedCAListViewData)
.where('_id = ' + $event.currentTarget.id)
.select('_Title');
//console.log(CITitle);
//console.log($scope.selectedCAListViewData);
$rootScope.ViewTitle = CITitle[0]._Title;
}
else {
$rootScope.ViewTitle = $event.currentTarget.textContent;
}
localStorage.setItem("currentViewTitleFromJson", $rootScope.ViewTitle);
localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
var u = $location.url();
$location.url('/clinical-animations-detail');
//console.log($location.url('/clinical-animations-detail'));
}
$scope.openBodyView = function () {
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
$scope.voId = localStorage.getItem("currentBodyViewId");
// alert($scope.voId);
//once you get id in scope push detail in jspanel content
var openViews;
if ($rootScope.openViews.length > 0) {
openViews = new jinqJs()
.from($rootScope.openViews)
.where("BodyViewId==" + $scope.voId)
.select();
}
var counter = 1;
var tittle = localStorage.getItem("currentViewTitleFromJson");
if (openViews != null && openViews.length > 0) {
angular.forEach(openViews, function (value, key) {
if (value.body - views == tittle) {
tittle = localStorage.getItem("currentViewTitleFromJson") + counter++;
$rootScope.currentActiveViewTitle = tittle;
localStorage.setItem("currentViewTitle", tittle);
}
});
}
else {
localStorage.setItem("currentViewTitle", tittle);
}
//alert(localStorage.getItem("currentViewTitle"));
var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist_mp4link.json')
promise.then(
function (result) {
$scope.AnimationData = result;
$scope.CAlistViewData = $scope.AnimationData.root.CAData;
var clickedCAVideo = [];
clickedCAVideo = new jinqJs()
.from($scope.CAlistViewData)
.where('_id == ' + $scope.voId)
.select('_Video','_LowerSummary');
$scope.clickedCAVideo = clickedCAVideo[0]._Video;
$scope.clickedCASummary = clickedCAVideo[0]._LowerSummary
if ($scope.clickedCAVideo.length > 0 && $scope.clickedCASummary.length > 0) {
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
$.jsPanel({
id: 'caVideoPanel',
selector: '.caView',
theme: 'success',
currentController: 'CAController',
parentSlug: 'clinical-animations',
content: '' +
'
' + $scope.clickedCASummary + '
' +
'
',
//ajax: {
// url: 'app/views/ca/ca-view-detail.html'
//},
title: localStorage.getItem("currentViewTitle"),
position: {
top: 70,
left: 1,
},
size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight()},
});
$rootScope.currentSlug = 'clinical-animations-detail';
$rootScope.openViews.push(
{
"module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
"slug": $rootScope.currentSlug
});
}
},
function (error) {
// handle errors here
console.log(' $scope.AnimationData = ' + error.statusText);
}
);
//console.log($rootScope.openViews);
$('#CAView').css("height", $(window).outerHeight());
$('#CAView').css("width", $(window).outerWidth());
}
}]
);