AIA.controller("CAController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "BodyRegions", "BodySystems", "MedicalSpecialties", "DataService", function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, BodyRegions, BodySystems, MedicalSpecialties, DataService) { // $rootScope.currentActiveModuleTitle = pages[4].name; $scope.showTabButton = true; $scope.AnimationData; $scope.CAAllBodyRegion = []; $scope.CAAllBodySystem = []; $scope.CAAllSpeciality = []; $scope.selectedCAListViewData = []; $scope.searchCAListViewData = []; $scope.SelectedCAthumbImage = []; $scope.SelectedCAImage = []; $scope.SelectedCASummary = []; $scope.filterstring = false; $scope.hostedServer = "http://aia5.adam.com/graphics/Multimedia/en/"; $scope.hostedFolderId; $scope.idSelected; $scope.query = { selectedbodyregion: '', selectedbodysystem: '', selectedspecialty: '', }; $scope.setActiveTab = function (tabToSet) { $scope.activeTab = tabToSet; localStorage.setItem("currentCATabView", $scope.activeTab); }; $scope.$on('$viewContentLoaded', function (event) { if ($rootScope.refreshcheck == null) { $location.path('/'); } // code that will be executed ... // every time this view is loaded //get current path var currentURL = $location.path(); var selectedModuleName = ''; //set module title angular.forEach($rootScope.userModules, function (value, key) { if (value.slug === currentURL.replace('/', '')) { selectedModuleName = value.name; } $rootScope.currentActiveModuleTitle = selectedModuleName; }) $scope.LoadCAJsonData(); $scope.CAAllBodyRegion = BodyRegions; $scope.CAAllBodySystem = BodySystems; $scope.CAAllSpeciality = MedicalSpecialties; $scope.scroll(); //push the details of open module in array $rootScope.openModules $rootScope.openModules.push({ "ModuleId": 5 }); //set the local storage var curtab = $rootScope.getLocalStorageValue("currentCATabView"); //if (curtab == 2) { // $scope.setActiveTab(2); //} if (curtab == 2) { $scope.setActiveTab(2); var curSelectedRowId = $rootScope.getLocalStorageValue("CASelectedRowId"); if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') { $scope.reRunSearchOnLoad(); $scope.idSelected = curSelectedRowId; $scope.ReloadListViewImageDiv($scope.idSelected); } else { $scope.reRunSearchOnLoad() $scope.idSelected = ''; } } else { $scope.setActiveTab(1); $scope.reRunSearchOnLoad(); } }); $scope.reRunSearchOnLoad = function () { var curBodyRegion = $rootScope.getLocalStorageValue("CACurBodyRegion"); if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null && curBodyRegion !== '') { $scope.query.selectedbodyregion = curBodyRegion; } else { $scope.query.selectedbodyregion = ""; } var curBodySystem = $rootScope.getLocalStorageValue("CACurBodySystem"); if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null && curBodySystem !== '') { $scope.query.selectedbodysystem = curBodySystem; } else { $scope.query.selectedbodysystem = ""; } var curSpeciality = $rootScope.getLocalStorageValue("CACurSpeciality"); if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null && curSpeciality !== '') { $scope.query.selectedspecialty = curSpeciality; } else { $scope.query.selectedspecialty = ""; } if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedspecialty == "") { $scope.loadAllCA(); } else { $scope.ApplySearch($scope.query); } } $scope.LoadCAJsonData = function () { 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); }, function (error) { // handle errors here console.log(' $scope.AnimationData = ' + error.statusText); } ); }; $scope.loadAllCA = function () { 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 = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); }); $('#' + $rootScope.getLocalStorageValue("currentBodyViewId")).find('.thumbnail').addClass('HightLightThumbnail'); $timeout(function () { if ($rootScope.getLocalStorageValue('CAGridViewScroll') !== null && $location.url() == "/clinical-animations") { $('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('CAGridViewScroll') }, 'slow'); } }, 300); }, function (error) { // handle errors here console.log(' $scope.AnimationData = ' + error.statusText); } ); } $scope.IsVisible = function () { $scope.scroll(); } $scope.showItem = function (id) { //console.log(id); $scope.idSelected = id; localStorage.setItem("CASelectedRowId", id); //Set the vertical scroll value of the table. var y = $('#ListViewDiv').scrollTop(); localStorage.setItem("CAListViewScroll", y); $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 = ""; query.selectedbodysystem = ""; query.selectedspecialty = ""; //set localstorage values localStorage.setItem("CACurBodyRegion", ''); localStorage.setItem("CACurBodySystem", ''); localStorage.setItem("CACurSpeciality", ''); localStorage.setItem("CAListViewScroll", ''); localStorage.setItem("CASelectedRowId", ""); $scope.filterstring = false; if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $('#ListViewDiv').scrollTop(0); $scope.hideListViewDiv(); while ($scope.searchCAListViewData.length) { $scope.searchCAListViewData.pop(); } if ($rootScope.getLocalStorageValue("currentCATabView") == 2) { localStorage.setItem("CASelectedRowId", ""); $scope.hiderow = false; } $scope.loadAllCA(); } // for "Intracytoplasmic sperm injection (ICSI)" case, the Body region is not required so we have added "_BodyRegion": "None" which was actually not available in origincal flex file. $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 && query.selectedbodyregion !== "") { filtercount = filtercount + 1; localStorage.setItem("CACurBodyRegion", query.selectedbodyregion); } else { localStorage.setItem("CACurBodyRegion", ''); } if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null && query.selectedbodysystem !== "") { filtercount = filtercount + 1; localStorage.setItem("CACurBodySystem", query.selectedbodysystem); } else { localStorage.setItem("CACurBodySystem", ''); } if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null && query.selectedspecialty !== "") { filtercount = filtercount + 1; localStorage.setItem("CACurSpeciality", query.selectedspecialty); } else { localStorage.setItem("CACurSpeciality", ''); } 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) { var selectimg = true; var count = 0; if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null && query.selectedbodyregion !== "") { 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 && query.selectedbodysystem !== "") { 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 && query.selectedspecialty !== "") { 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 = $('
' + '
' + '' + '

' + value._Title + '

').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 }); } }); $('table > #ListViewDiv > #searchAnimation').remove(); //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); $('table > #ListViewDiv > #searchAnimation').remove(); $('#ListViewDiv').append('No animation found for the selected search criteria!'); } }, function (error) { // handle errors here console.log(' $scope.AnimationData = ' + error.statusText); } ); } $scope.scroll = function () { $("html,body").scrollTop(0); } $scope.openView = function ($event) { $rootScope.disableAnnotationTBFn(); $rootScope.MenuModuleName = "CA"; //alert($rootScope.MenuModuleName); $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 CAGridViewScrollPosition = $($window).scrollTop(); localStorage.setItem('CAGridViewScroll', CAGridViewScrollPosition); var u = $location.url(); $location.url('/clinical-animations-detail'); //console.log($location.url('/clinical-animations-detail')); } $scope.openBodyView = function () { if ($rootScope.refreshcheck == null) { $location.path('/'); } if ($rootScope.disableAnnotationTB == true) { $('#AnnotaionPopupDiv').find('input, textarea, button, select,img,div').attr('disabled', 'disabled'); $('#slider-range-min-2').slider('disable'); $("#annotationpaintbrushsize").attr('disabled', 'disabled'); //$("#annotationpaintbrushsize").attr("href", "#"); } $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $scope.voId = $rootScope.getLocalStorageValue("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 = $rootScope.getLocalStorageValue("currentViewTitleFromJson"); localStorage.setItem("currentViewTitle", tittle); //if (openViews != null && openViews.length > 0) { // angular.forEach(openViews, function (value, key) { // if (value.body - views == tittle) { // tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++; // $rootScope.currentActiveViewTitle = tittle; // localStorage.setItem("currentViewTitle", tittle); // } // }); //} //else { // localStorage.setItem("currentViewTitle", tittle); //} //alert($rootScope.getLocalStorageValue("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', '_HostedFolderId'); $scope.clickedCAVideo = clickedCAVideo[0]._Video; $scope.clickedCASummary = clickedCAVideo[0]._LowerSummary; $scope.hostedFolderId = clickedCAVideo[0]._HostedFolderId; $scope.poster = $scope.hostedServer + $scope.hostedFolderId + "/" + $scope.hostedFolderId + ".jpg"; $scope.ad = $scope.hostedServer + $scope.hostedFolderId + "/" + $scope.hostedFolderId + "_ad.mp4"; $scope.HDVid = $scope.hostedServer + $scope.hostedFolderId + "/" + $scope.hostedFolderId + "_HD.mp4"; $scope.webm = $scope.hostedServer + $scope.hostedFolderId + "/" + $scope.hostedFolderId + ".webm"; $scope.ogv = $scope.hostedServer + $scope.hostedFolderId + "/" + $scope.hostedFolderId + ".ogv"; $scope.playerScript = "~/../libs/video_4_12_11/video_4_12_11.js"; //$scope.vtt = $scope.hostedServer + $scope.hostedFolderId + "/" + $scope.hostedFolderId + ".vtt" $scope.vtt = "~/../content/data/vtt/" + $scope.hostedFolderId + ".vtt"; console.log($scope.vtt); 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: $rootScope.getLocalStorageValue("currentViewTitle"), position: { top: 70, left: 1, }, size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, }); $rootScope.currentSlug = 'clinical-animations-detail'; $('html, body').animate({ scrollTop: 0 }); $rootScope.openViews.push( { "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, "slug": $rootScope.currentSlug }); var jspContentHeight = $('.jsPanel-content').height(); var videoHeight = $('#divplayerinlineVideo div').height(); if (videoHeight <= 0) videoHeight = 360; var textH = $('.video-subtitle').height(); textH = textH + 40; var blackBorderHeight = jspContentHeight - (videoHeight + textH); if ($('.jsPanel-content').length > 0) { $('.video-subtitle').css('margin-bottom', blackBorderHeight); $('#divplayerinlineVideo').css('background', '#fff'); //Android > Clinical Animations > The animation does not fit to the screen in the Landscape mode. var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { $('.jsPanel-content').css("width", "100%"); } } } }, 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()); } $scope.loadCAPlayer = function (summary, link, vidNumber) { $scope.clickedCASummary = summary; $scope.clickedCAVideo = link; $scope.videoNumber = vidNumber; }; $scope.ReloadListViewImageDiv = function (id) { //console.log(id); $scope.idSelected = id; $scope.hiderow = true; 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; var SelectedCAthumbImage = []; SelectedCAthumbImage = new jinqJs() .from($scope.AnimationData.root.CAData) .where('_id = ' + id) .select('_ThumbnailImage', '_Summary', '_id', '_Title'); //console.log($scope.selectedCAListViewData); $scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage; $scope.SelectedCASummary = SelectedCAthumbImage[0]._Summary; $scope.SelectedCAId = SelectedCAthumbImage[0]._id; $scope.SelectedCATitle = SelectedCAthumbImage[0]._Title; //Set the scroll position of the tablebody to show selected row. var curCAListViewScroll = $rootScope.getLocalStorageValue("CAListViewScroll"); if (typeof (curCAListViewScroll) !== "undefined" && curCAListViewScroll !== null && curCAListViewScroll !== '') { if (typeof InstallTrigger !== 'undefined') { $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue("CAListViewScroll") }); } else { $('#ListViewDiv').scrollTop($rootScope.getLocalStorageValue("CAListViewScroll")); } } //else { // $('#ListViewDiv').scrollTop(0); //} }, function (error) { // handle errors here console.log(' $scope.AnimationData = ' + error.statusText); } ); }; $scope.hideListViewDiv = function () { if ($rootScope.getLocalStorageValue("currentCATabView") == 2) { localStorage.setItem("CASelectedRowId", ""); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $scope.hiderow = false; } } }] );