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.searchCAlistViewData = [];
$scope.SelectedCAthumbImage = [];
$scope.SelectedCAImage = [];
$scope.SelectedCASummary = [];
$scope.filterstring = false;
$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;
$('#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');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
var SelectedCASummary = [];
SelectedCASummary = new jinqJs()
.from($scope.selectedCAlistViewData)
.where('_id = ' + id)
.select('_Summary');
$scope.SelectedCASummary = SelectedCASummary[0]._Summary
// alert($scope.SelectedCAImage + "\n" + $scope.SelectedCASummary);
}
else {
if ($scope.searchCAlistViewData.length > 0) {
var SelectedCAthumbImage = [];
SelectedCAthumbImage = new jinqJs()
.from($scope.searchCAlistViewData)
.where('_id = ' + id)
.select('_ThumbnailImage');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
var SelectedCASummary = [];
SelectedCASummary = new jinqJs()
.from($scope.searchCAlistViewData)
.where('_id = ' + id)
.select('_Summary');
$scope.SelectedCASummary = SelectedCASummary[0]._Summary
// alert($scope.SelectedCAImage + "\n" + $scope.SelectedCASummary);
}
}
};
$scope.Reset = function (query) {
query.selectedbodyregion = "";
query.selectedbodysystem = "";
query.selectedspecialty = "";
$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
});
}
});
}
$scope.scroll = function () {
$("html,body").scrollTop(0);
}
$scope.openView = function ($event) {
//localStorage.setItem("currentViewTitleFromJson", $event.currentTarget.textContent);
//localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
//if ($scope.filterstring == false) {
// var SelectedCAImage = [];
// SelectedCAImage = new jinqJs()
// .from($scope.selectedCAlistViewData)
// .where('_id = ' + $event.currentTarget.id)
// .select('_contentImage');
// $scope.SelectedCAImage = "~/../content/images/ci/images/" + SelectedCAImage[0]._contentImage;
// var SelectedCASummary = [];
// SelectedCASummary = new jinqJs()
// .from($scope.selectedCAlistViewData)
// .where('_id = ' + $event.currentTarget.id)
// .select('_Summary');
// $scope.SelectedCASummary = SelectedCASummary[0]._Summary
// // alert($scope.SelectedCAImage + "\n" + $scope.SelectedCASummary);
//}
//else {
// if ($scope.searchCAlistViewData.length > 0) {
// var SelectedCAImage = [];
// SelectedCAImage = new jinqJs()
// .from($scope.searchCAlistViewData)
// .where('_id = ' + $event.currentTarget.id)
// .select('_contentImage');
// $scope.SelectedCAImage = "~/../content/images/ci/images/" + SelectedCAImage[0]._contentImage;
// var SelectedCASummary = [];
// SelectedCASummary = new jinqJs()
// .from($scope.searchCAlistViewData)
// .where('_id = ' + $event.currentTarget.id)
// .select('_Summary');
// $scope.SelectedCASummary = SelectedCASummary[0]._Summary
// // alert($scope.SelectedCAImage + "\n" + $scope.SelectedCASummary);
// }
//}
//$.jsPanel({
// position: {
// top: 100,
// left: 1,
// },
// size: { width: $(window).outerWidth() - 40, height: $(window).outerHeight() - 130 },
// title: $event.currentTarget.textContent,
// theme: 'success',
// content: '' +
// '

' +
// '
' + $scope.SelectedCASummary + '
' +
// '
',
//});
}
}]
);