AIA.controller("CIController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "MedicalSpecialties", "DataService", function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, BodyRegions, BodySystems, ViewOrientations, ImageTypes, MedicalSpecialties, DataService) { $rootScope.currentActiveModuleTitle = pages[3].name; $scope.showme = true; $scope.IllustrationData; $scope.CIAllBodyRegion = []; $scope.CIAllBodySystem = []; $scope.CIAllOrientation = []; $scope.CIAllImageType = []; $scope.CIAllSpeciality = []; $scope.searchCIListViewData = []; $scope.SelectedCIthumbImage = []; $scope.SelectedCIImage = []; $scope.SelectedCISummary = []; $scope.SelectedCIId = []; $scope.SelectedCITitle = []; $scope.selectedCIListViewData = []; $scope.filterstring = false; $scope.query = { selectedbodyregion: null, selectedbodysystem: null, selectedorientation: null, selectedimagetype: null, selectedspecialty: null, }; $scope.$on('$viewContentLoaded', function (event) { // code that will be executed ... // every time this view is loaded $scope.CIAllBodyRegion = BodyRegions; $scope.CIAllBodySystem = BodySystems; $scope.CIAllOrientation = ViewOrientations; $scope.CIAllImageType = ImageTypes; $scope.CIAllSpeciality = MedicalSpecialties; $scope.scroll(); //push the details of open module in array $rootScope.openModules $rootScope.openModules.push({ "ModuleId": 4 }); }); var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') promise.then( function (result) { $scope.IllustrationData = result; $scope.selectedCIListViewData = $scope.IllustrationData.root.CIData; $('#grid-view').empty(); angular.forEach($scope.selectedCIListViewData, function (value, key) { $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); }); }, function (error) { // handle errors here console.log(' $scope.IllustrationData = ' + error.statusText); } ); $scope.IsVisible = function () { $scope.scroll(); } $scope.showItem = function (id) { // console.log(id); $scope.hiderow = true; if ($scope.filterstring == false) { var SelectedCIthumbImage = []; SelectedCIthumbImage = new jinqJs() .from($scope.selectedCIListViewData) .where('_id = ' + id) .select('_ThumbnailImage', '_Summary', '_id', '_Title'); $scope.SelectedCIthumbImage = "~/../content/images/ci/thumbnails/" + SelectedCIthumbImage[0]._ThumbnailImage; $scope.SelectedCISummary = SelectedCIthumbImage[0]._Summary; $scope.SelectedCIId = SelectedCIthumbImage[0]._id; $scope.SelectedCITitle = SelectedCIthumbImage[0]._Title; } else { if ($scope.searchCIListViewData.length > 0) { var SelectedCIthumbImage = []; SelectedCIthumbImage = new jinqJs() .from($scope.searchCIListViewData) .where('_id = ' + id) .select('_ThumbnailImage', '_Summary', '_id', '_Title'); $scope.SelectedCIthumbImage = "~/../content/images/ci/thumbnails/" + SelectedCIthumbImage[0]._ThumbnailImage; $scope.SelectedCISummary = SelectedCIthumbImage[0]._Summary; $scope.SelectedCIId = SelectedCIthumbImage[0]._id; $scope.SelectedCITitle = SelectedCIthumbImage[0]._Title; } } }; $scope.Reset = function (query) { //query.selectedbodyregion = ""; //query.selectedbodysystem = ""; //query.selectedorientation = ""; //query.selectedimagetype = ""; //query.selectedspecialty = ""; query.selectedbodyregion = null; query.selectedbodysystem = null; query.selectedorientation = null; query.selectedimagetype = null; query.selectedspecialty = null; $scope.filterstring = false; while ($scope.searchCIListViewData.length) { $scope.searchCIListViewData.pop(); } $('#grid-view').empty(); angular.forEach($scope.selectedCIListViewData, function (value, key) { $scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage; var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); }); } $scope.ApplySearch = function (query) { alert(query.selectedbodyregion); debugger; $scope.filterstring = true; while ($scope.searchCIListViewData.length) { $scope.searchCIListViewData.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.selectedorientation) !== "undefined" && query.selectedorientation !== null) { filtercount = filtercount + 1; } if (typeof (query.selectedimagetype) !== "undefined" && query.selectedimagetype !== null) { filtercount = filtercount + 1; } if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null) { filtercount = filtercount + 1; } angular.forEach($scope.selectedCIListViewData, 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.selectedorientation) !== "undefined" && query.selectedorientation !== null) { var posorientation = value._ViewOrientation.indexOf(query.selectedorientation); if (posorientation > -1) { count = count + 1; selectimg = true; } else { selectimg = false; count = count - 1; } } if (typeof (query.selectedimagetype) !== "undefined" && query.selectedimagetype !== null) { var posimagetype = value._ImageType.indexOf(query.selectedimagetype); if (posimagetype > -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/ci/thumbnails/" + value._ThumbnailImage; var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); $scope.searchCIListViewData.push( { "_id": value._id, "_ImageId": value._ImageId, "_Title": value._Title, "_contentImage": value._contentImage, "_ThumbnailImage": value._ThumbnailImage, "_BodySystem": value._BodySystem, "_BodyRegion": value._BodyRegion, "_ViewOrientation": value._ViewOrientation, "_MedicalSpecialty": value._MedicalSpecialty, "_ImageType": value._ImageType, "_Summary": value._Summary }); } }); //Show Error Message in case of gridview if no data is found if ($scope.searchCIListViewData.length == 0) { var $el = $('
No illustration 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.selectedCIListViewData) .where('_id = ' + $event.currentTarget.id) .select('_Title'); // console.log(CITitle); // console.log($scope.selectedCIListViewData); $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-illustrations-detail'); // console.log($location.url('/clinical-illustrations-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/ci/ci_dat_contentlist.json') promise.then( function (result) { $scope.CIllustrationData = result; $scope.CIlistViewData = $scope.CIllustrationData.root.CIData; var clickedCIImage = []; clickedCIImage = new jinqJs() .from($scope.CIlistViewData) .where('_id == ' + $scope.voId) .select('_contentImage'); $scope.clickedCIImage = "~/../content/images/ci/images/" + clickedCIImage[0]._contentImage; var clickedCISummary = []; clickedCISummary = new jinqJs() .from($scope.CIlistViewData) .where('_id == ' + $scope.voId) .select('_Summary'); $scope.clickedCISummary = clickedCISummary[0]._Summary if (clickedCIImage.length > 0 && clickedCISummary.length > 0) { $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); //$.jsPanel({ // id: 'ciImagePanel', // selector: '.ciView', // theme: 'success', // currentController: 'CIController', // parentSlug: 'clinical-illustrations', // content: '
' + // '
' + // '

' + $scope.clickedCISummary + '

'+ // '
' + // '
', // title: localStorage.getItem("currentViewTitle"), // position: { // top: 70, // left: 1, // }, $.jsPanel({ id: 'ciImagePanel', selector: '.ciView', theme: 'success', currentController: 'CIController', parentSlug: 'clinical-illustrations', content: '
' + '
' + '

' + $scope.clickedCISummary + '

' + '
' + '
', //ajax: { // url: 'app/views/ci/ci-view-detail.html' //}, title: localStorage.getItem("currentViewTitle"), position: { top: 70, left: 1, }, //size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, }); $rootScope.currentSlug = 'clinical-illustrations-detail'; $rootScope.openViews.push( { "module": $rootScope.currentActiveModuleTitle, "body-views": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, "slug": $rootScope.currentSlug }); //var e1 = angular.element(document.getElementById("CIView")); //$timeout(function () { // //$compile(e1.contents())($scope) // var $el = $('
' + // '
' + // '

' + $scope.clickedCISummary + '

' + // '
' + // '
').appendTo('#ciView'); // $compile($el)($scope); //}, 250); // $compile(e1.contents())($scope); //$('#ciView').css("height", $(window).outerHeight() - 110); //$('#ciView').css("width", $(window).outerWidth() - 10); } }, function (error) { // handle errors here console.log(' $scope.CIllustrationData = ' + error.statusText); } ); // console.log($rootScope.openViews); $('#CIView').css("height", $(window).outerHeight()); $('#CIView').css("width", $(window).outerWidth()); } }] );