AIA.controller("CIController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "MedicalSpecialties", "DataService", "ModuleService", "$interval", function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, BodyRegions, BodySystems, ViewOrientations, ImageTypes, MedicalSpecialties, DataService, ModuleService, $interval) { $scope.CIAllBodyRegion = []; $scope.CIAllBodySystem = []; $scope.CIAllOrientation = []; $scope.CIAllImageType = []; $scope.CIAllSpeciality = []; $scope.selectedCIListViewData = []; //$scope.searchCIListViewData = []; $scope.SelectedCIthumbImage = []; $scope.SelectedCISummary = []; $scope.SelectedCIId = []; $scope.SelectedCITitle = []; $scope.filterstring = false; $scope.idSelected; $scope.srollListView; $scope.showTabButton = true; $scope.query = { selectedbodyregion: '', selectedbodysystem: '', selectedorientation: '', selectedimagetype: '', selectedspecialty: '', }; //************************************ $scope.setActiveTab = function (tabToSet) { if(tabToSet=="" ||tabToSet==undefined) { $scope.activeTab=1; } else { $scope.activeTab = tabToSet; } localStorage.setItem("currentCITabView", $scope.activeTab); if ($scope.activeTab == 1) { $('#grid-view').css("display", "block"); $('#list-view').css("display", "none"); } else { $('#grid-view').css("display", "none"); $('#list-view').css("display", "block"); } }; $scope.ObjectAttribute=function(windowviewid) { var windata={ 'multiwinid': windowviewid, 'IllustrationData': [], 'searchCIListViewData': [], 'CIImagePath': '', 'ImageSummary': '', 'moduleName': '', 'currentViewTitle': '', 'parentSlugName': '', 'currentSlug': '', 'imageId': '', 'imageName': '', 'isTextVisible': true, 'y': 0, 'x': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': true, 'minmaxAutoEvent':true, 'annotationData':{shapeStates:[],paintCanvasState:[]}, }; return windata; } $scope.initializeCIWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) { if (isOpenWithExistsModule || openPanelNo == 0) { if ($rootScope.CIWindowData != undefined) { $rootScope.CIWindowData.length = 0; } else { $rootScope.CIWindowData = []; } $rootScope.CIWindowData.push($scope.ObjectAttribute(windowviewid)); } else { var isNewWindow = true; for (var k = 0; k < $rootScope.CIWindowData.length; k++) { if ($rootScope.CIWindowData[k].multiwinid == windowviewid) { isNewWindow = false; break; } } if (isNewWindow) { $rootScope.CIWindowData.push($scope.ObjectAttribute(windowviewid)); } } } $scope.GetCIwindowStoreData = function (windowviewid, keyname) { for (var x = 0 ; x < $rootScope.CIWindowData.length; x++) { if ($rootScope.CIWindowData[x].multiwinid == windowviewid) { return $rootScope.CIWindowData[x][keyname]; } } } $scope.SetCIwindowStoreData = function (windowviewid, keyname, value) { for (var x = 0 ; x < $rootScope.CIWindowData.length; x++) { if ($rootScope.CIWindowData[x].multiwinid == windowviewid) { $rootScope.CIWindowData[x][keyname] = value; } } } // access from home controller $rootScope.GetCIwindowData=function(windowviewid,keyname) { for(var x=0 ;x < $rootScope.CIWindowData.length;x++){ if($rootScope.CIWindowData[x].multiwinid==windowviewid) { return $rootScope.CIWindowData[x][keyname]; } } } // access from home controller $rootScope.SetCIwindowData=function(windowviewid,keyname,data) { for(var x=0 ;x < $rootScope.CIWindowData.length;x++){ if($rootScope.CIWindowData[x].multiwinid==windowviewid) { $rootScope.CIWindowData[x][keyname]=data; } } } $scope.DisableUI = function () { var ciImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < ciImagePanelConetent.length; i++) { ciImagePanelConetent[i].style.pointerEvents = "none"; ciImagePanelConetent[i].style.opacity = "0.7"; } $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); // CB module disable all $('#HomeContainerDiv').css('pointer-events', 'none'); $('#HomeContainerDiv').css('opacity', '0.7'); } $scope.EnableUI = function () { var ciImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < ciImagePanelConetent.length; i++) { ciImagePanelConetent[i].style.pointerEvents = "auto"; ciImagePanelConetent[i].style.opacity = "1"; } $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); // CB module enable all $('#HomeContainerDiv').css('pointer-events', 'auto'); $('#HomeContainerDiv').css('opacity', '1'); } $scope.loadAIModuleById = function (moduleId) { $rootScope.isCallFromOtherModule = undefined; $rootScope.MULTI_VIEW_ID += 1 // store exist module in module service var ExistData = ModuleService.getModuleData("CLINICAL_ILLUSTRATIONS"); if (ExistData != undefined && ExistData.length > 0) { // clear all module data before open new module in cb ModuleService.ClearWinDataByModule(ExistData.mType); } var newWindowData = { "mType": 'CLINICAL_ILLUSTRATIONS', }; ModuleService.setModuleData(newWindowData, 0); // close/remove prev panel when in minimised mode if($rootScope.CIWindowData!=undefined) { if($rootScope.CIWindowData.length>0) { for(var x=0 ;x < $rootScope.CIWindowData.length;x++){ var winid=$rootScope.CIWindowData[x].multiwinid; if ($('#ciImagePanel_' + winid).html() != undefined) { $('#ciImagePanel_' + winid).remove(); } } $rootScope.CIWindowData=[]; } } $scope.initializeCIWindowData($rootScope.MULTI_VIEW_ID, true, undefined); $scope.DisableUI(); 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; }) var curtab = $rootScope.getLocalStorageValue("currentCITabView"); $scope.setActiveTab(curtab) $scope.SetCIwindowStoreData($rootScope.MULTI_VIEW_ID, 'moduleName', "Clinical Illustrations"); $scope.LoadCIJsonData($rootScope.MULTI_VIEW_ID); $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 }); //set the local storage setTimeout(function () { var curtab = $rootScope.getLocalStorageValue("currentCITabView"); //call time interval function until load Illustration data var timeintval = null; timeintval = $interval(function () { var IllustrationData = $scope.GetCIwindowStoreData($rootScope.MULTI_VIEW_ID, 'IllustrationData'); if (IllustrationData.length>0) { $scope.stopIntervalCI(); if (curtab == 2) { var curSelectedRowId = $rootScope.getLocalStorageValue("CISelectedRowId"); if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') { $scope.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID); $scope.idSelected = curSelectedRowId; $scope.ReloadListViewImageDiv($scope.idSelected, $rootScope.MULTI_VIEW_ID); } else { $scope.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID) $scope.idSelected = ''; } } else { $scope.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID); } } else { console.log("waiting for Illustration Data"); } }, 100); $scope.stopIntervalCI = function () { if (angular.isDefined(timeintval)) { $interval.cancel(timeintval); timeintval = undefined; } }; }, 100); } $scope.reRunSearchOnLoad = function (windowviewid) { var curBodyRegion = $rootScope.getLocalStorageValue("CICurBodyRegion"); if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null && curBodyRegion !== '') { $scope.query.selectedbodyregion = curBodyRegion; } else { $scope.query.selectedbodyregion = ""; } var curBodySystem = $rootScope.getLocalStorageValue("CICurBodySystem"); if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null && curBodySystem !== '') { $scope.query.selectedbodysystem = curBodySystem; } else { $scope.query.selectedbodysystem = ""; } var curOrientation = $rootScope.getLocalStorageValue("CICurOrientation"); if (typeof (curOrientation) !== "undefined" && curOrientation !== null && curOrientation !== '') { $scope.query.selectedorientation = curOrientation; } else { $scope.query.selectedorientation = ""; } var curImageType = $rootScope.getLocalStorageValue("CICurImageType"); if (typeof (curImageType) !== "undefined" && curImageType !== null && curImageType !== '') { $scope.query.selectedimagetype = curImageType; } else { $scope.query.selectedimagetype = ""; } var curSpeciality = $rootScope.getLocalStorageValue("CICurSpeciality"); if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null && curSpeciality !== '') { $scope.query.selectedspecialty = curSpeciality; } else { $scope.query.selectedspecialty = ""; } if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedorientation == "" && $scope.query.selectedimagetype == "" && $scope.query.selectedspecialty == "") { $scope.loadAllCI(windowviewid); } else { $scope.ApplySearch($scope.query, windowviewid); } } $scope.LoadCIJsonData = function (windowviewid) { var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') promise.then( function (result) { var IllustrationData = new jinqJs() .from(result.root.CIData) .orderBy([{ field: '_Title', sort: 'asc' }]) .select(); $scope.SetCIwindowStoreData(windowviewid, 'IllustrationData', IllustrationData); $scope.selectedCIListViewData = IllustrationData; }, function (error) { $scope.EnableUI(); // handle errors here console.log(' $scope.IllustrationData = ' + error.statusText); } ); }; $scope.loadAllCI = function (windowviewid) { $scope.selectedCIListViewData = $scope.GetCIwindowStoreData(windowviewid, 'IllustrationData'); $('#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); }); $timeout(function () { $('#' + $rootScope.getLocalStorageValue("currentImageId")).find('.thumbnail').addClass('HightLightThumbnail'); if ($rootScope.getLocalStorageValue('CIGridViewScroll') !== null && $location.url() == "/clinical-illustrations") { $("#grid-view").animate({ scrollTop: $rootScope.getLocalStorageValue('CIGridViewScroll') }); } }, 100); $timeout(function () { $scope.EnableUI(); $scope.ResetGridListLength(); }, 400); } $scope.IsVisible = function () { $scope.scroll(); } $scope.showItem = function (id, windowviewid) { if (windowviewid == undefined) windowviewid = $rootScope.MULTI_VIEW_ID; $scope.idSelected = id; localStorage.setItem("CISelectedRowId", id); //Set the vertical scroll value of the table. var y = $('#ListViewDiv').scrollTop(); localStorage.setItem("CIListViewScroll", y); $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 { var searchCIListViewData = $scope.GetCIwindowStoreData(windowviewid, 'searchCIListViewData'); if (searchCIListViewData.length > 0) { var SelectedCIthumbImage = []; SelectedCIthumbImage = new jinqJs() .from(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, windowviewid) { if (windowviewid == undefined) // call from also home controller list manager windowviewid = $rootScope.MULTI_VIEW_ID; $scope.DisableUI(); query.selectedbodyregion = ""; query.selectedbodysystem = ""; query.selectedorientation = ""; query.selectedimagetype = ""; query.selectedspecialty = ""; //set localstorage values localStorage.setItem("CICurBodyRegion", ''); localStorage.setItem("CICurBodySystem", ''); localStorage.setItem("CICurOrientation", ''); localStorage.setItem("CICurImageType", ''); localStorage.setItem("CICurSpeciality", ''); localStorage.setItem("CISelectedRowId", ""); localStorage.setItem("CIListViewScroll", ''); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $('#ListViewDiv').scrollTop(0); $scope.hideListViewDiv(); $scope.filterstring = false; $scope.SetCIwindowStoreData(windowviewid, 'searchCIListViewData', []); setTimeout(function(){ $scope.loadAllCI(windowviewid); },200) } $scope.ApplySearch = function (query, windowviewid) { $scope.DisableUI(); if (windowviewid == undefined) { windowviewid = $rootScope.MULTI_VIEW_ID; } setTimeout(function(){ $scope.FilterSearch(query, windowviewid) },200) } $scope.FilterSearch = function (query, windowviewid) { $scope.filterstring = true; $scope.SetCIwindowStoreData(windowviewid, 'searchCIListViewData', []); filtercount = 0; if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null && query.selectedbodyregion !== "")) { filtercount = filtercount + 1; localStorage.setItem("CICurBodyRegion", query.selectedbodyregion); } else { localStorage.setItem("CICurBodyRegion", ''); } if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null && query.selectedbodysystem !== "")) { filtercount = filtercount + 1; localStorage.setItem("CICurBodySystem", query.selectedbodysystem); } else { localStorage.setItem("CICurBodySystem", ''); } if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null && query.selectedorientation !== '')) { filtercount = filtercount + 1; localStorage.setItem("CICurOrientation", query.selectedorientation); } else { localStorage.setItem("CICurOrientation", ''); } if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null && query.selectedimagetype !== '')) { filtercount = filtercount + 1; localStorage.setItem("CICurImageType", query.selectedimagetype); } else { localStorage.setItem("CICurImageType", ''); } if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null && query.selectedspecialty !== '')) { filtercount = filtercount + 1; localStorage.setItem("CICurSpeciality", query.selectedspecialty); } else { localStorage.setItem("CICurSpeciality", ''); } $scope.selectedCIListViewData = $scope.GetCIwindowStoreData(windowviewid, 'IllustrationData'); $('#grid-view').empty(); var cilistviewdata = []; angular.forEach($scope.selectedCIListViewData, 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.selectedorientation) !== "undefined" && (query.selectedorientation !== null && query.selectedorientation !== "")) { 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 && query.selectedimagetype !== "")) { 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 && 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/ci/thumbnails/" + value._ThumbnailImage; var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); cilistviewdata.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 }); } }); $('table > #ListViewDiv > #searchItem').remove(); $scope.SetCIwindowStoreData(windowviewid, 'searchCIListViewData', cilistviewdata); $scope.searchCIListViewData = cilistviewdata; //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); $('table > #ListViewDiv > #searchItem').remove(); $('#ListViewDiv').append('No illustration found for the selected search criteria!'); } $timeout(function () { $scope.EnableUI(); $scope.ResetGridListLength(); }, 400); } $scope.ResetGridListLength=function() { var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { if(screen.height<=768) { $('#grid-view').css({"height":"535","overflow":"scroll"}); $('#ListViewDiv').css({"height":"290","overflow":"scroll"}); } else if(screen.height<=1024) { $('#grid-view').css({"height":"720","overflow":"scroll"}); $('#ListViewDiv').css({"height":"480","overflow":"scroll"}); } else { $('#grid-view').css({"height":"950","overflow":"scroll"}); $('#ListViewDiv').css({"height":"880","overflow":"scroll"}); } } else { $('#grid-view').css({"height":"720","overflow":"scroll"}); $('#ListViewDiv').css({"height":"480","overflow":"scroll"}); } } $scope.scroll = function () { $("html,body").scrollTop(0); } $scope.openView = function ($event) { var windowviewid = $rootScope.MULTI_VIEW_ID; $rootScope.MenuModuleName = "CI"; $rootScope.disableAnnotationTB = false; $rootScope.CIAnotationIdentifyModeOff = true; if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") { var selectedTileData = []; selectedTileData = new jinqJs() .from($scope.selectedCIListViewData) .where('_id = ' + $event.currentTarget.id) .select(); $rootScope.ViewTitle = selectedTileData[0]._Title; } else { $rootScope.ViewTitle = $event.currentTarget.textContent; } // open module bu openresource var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource'); if (isopenResourceRequest == "true") { //set default module data var CIDopenData = { "id": $event.currentTarget.id, "mType": 'CLINICAL_ILLUSTRATIONS', "textVisible": true, "windowTitle": $rootScope.ViewTitle, "size": { height: 500, width: 900 }, "position": { x: 300, y: 110 } }; window.parent.AIAModuleOpenResourceInfo(CIDopenData); } else { localStorage.setItem("currentViewTitle", $rootScope.ViewTitle); localStorage.setItem("currentImageId", $event.currentTarget.id); $scope.SetCIwindowStoreData(windowviewid, 'currentViewTitle', $rootScope.ViewTitle); $scope.SetCIwindowStoreData(windowviewid, 'imageId', $event.currentTarget.id); var imageName = selectedTileData[0]._contentImage; $scope.SetCIwindowStoreData(windowviewid, 'imageName', imageName); var imagePath = "~/../content/images/ci/images/" + imageName; $scope.SetCIwindowStoreData(windowviewid, 'CIImagePath', imagePath); var selectedImageCISummary = selectedTileData[0]._Summary $scope.SetCIwindowStoreData(windowviewid, 'ImageSummary', selectedImageCISummary); // store image for export var tittle = $rootScope.getLocalStorageValue("currentViewTitle"); $rootScope.StoreTitleName(tittle); $rootScope.StoreOrgImageName(imageName); //Set the vertical scroll value of the Grid-View. var y = $("#grid-view").scrollTop(); localStorage.setItem("CIGridViewScroll", y); var u = $location.url(); $location.url('/clinical-illustrations-detail'); } } $rootScope.openCIBodyViewMain = function () { $scope.DisableUI(); if ($rootScope.isCallFromOtherModule) { $scope.CIModuleData = ModuleService.getModuleData("CLINICAL_ILLUSTRATIONS"); $scope.readyToLoad = true; $rootScope.CIWindowLoadComplete = false; $scope.wincount = 1; var winlen = $scope.CIModuleData.length; var timeint = null; timeint = $interval(function () { if ($scope.readyToLoad == true) { var windata = $scope.CIModuleData[$scope.wincount - 1]; $scope.openBodyView(windata); } $scope.readyToLoad = false; if ($scope.wincount < winlen && $rootScope.CIWindowLoadComplete == true) { $scope.wincount = $scope.wincount + 1; $rootScope.CIWindowLoadComplete = false; $scope.readyToLoad = true; } if ($scope.wincount == winlen && $rootScope.CIWindowLoadComplete == true) { $scope.stopInterval(); $scope.$emit("LoadModuleComplete", "CLINICAL_ILLUSTRATIONS"); } }, 100); $scope.stopInterval = function () { if (angular.isDefined(timeint)) { $interval.cancel(timeint); timeint = undefined; } }; } else { $scope.openBodyView(null); } } $scope.openBodyView = function (ciModuleData) { if ($rootScope.isCallFromOtherModule == true) { $scope.ciOpenInOtherModules = ciModuleData; $rootScope.MULTI_VIEW_ID += 1; var windowviewid = $rootScope.MULTI_VIEW_ID; $scope.initializeCIWindowData(windowviewid, false, $scope.ciOpenInOtherModules.currentWindowId); var moduleName = $scope.ciOpenInOtherModules.mType; $scope.SetCIwindowStoreData(windowviewid, 'moduleName', moduleName); var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json') promise.then( function (result) { var IllustrationData = new jinqJs() .from(result.root.CIData) .orderBy([{ field: '_Title', sort: 'asc' }]) .select(); // serial no of imageid var imageId = $scope.ciOpenInOtherModules.id; $scope.SetCIwindowStoreData(windowviewid, 'imageId', imageId); var selectedTileData = []; selectedTileData = new jinqJs() .from(IllustrationData) .where('_id == ' + imageId) .select(); var imageName = selectedTileData[0]._contentImage; $scope.SetCIwindowStoreData(windowviewid, 'imageName', imageName); var imagePath = "~/../content/images/ci/images/" + imageName; $scope.SetCIwindowStoreData(windowviewid, 'CIImagePath', imagePath); var selectedImageCISummary = selectedTileData[0]._Summary $scope.SetCIwindowStoreData(windowviewid, 'ImageSummary', selectedImageCISummary); var isTextVisible = $scope.ciOpenInOtherModules.textVisible; $scope.SetCIwindowStoreData(windowviewid, 'isTextVisible', isTextVisible); var ciTitle = $scope.ciOpenInOtherModules.anatomyTitle; $scope.SetCIwindowStoreData(windowviewid, 'currentViewTitle', ciTitle); localStorage.setItem("currentViewTitle", ciTitle); var isMaximize = $scope.ciOpenInOtherModules.maximised!=undefined?$scope.ciOpenInOtherModules.maximised:false; var isMinimize = $scope.ciOpenInOtherModules.minimised!=undefined?$scope.ciOpenInOtherModules.minimised:false; $scope.SetCIwindowStoreData(windowviewid, 'maximised', isMaximize); $scope.SetCIwindowStoreData(windowviewid, 'minimised', isMinimize); // store image for export $rootScope.StoreTitleName(ciTitle); $rootScope.StoreOrgImageName(selectedTileData[0]._contentImage); if($location.url()== "/curriculum-builder-detail") { $scope.SetCIwindowStoreData(windowviewid,'parentSlugName',($location.url()).replace('/', '')); } else { $scope.SetCIwindowStoreData(windowviewid,'parentSlugName','clinical-illustrations'); } $scope.loadCIllustration(windowviewid); }, function (error) { // handle errors here console.log(' $scope.CIllustrationData = ' + error.statusText); } ); } else { $scope.SetCIwindowStoreData($rootScope.MULTI_VIEW_ID, 'parentSlugName', 'clinical-illustrations'); $scope.loadCIllustration($rootScope.MULTI_VIEW_ID); } } $scope.loadCIllustration = function (windowviewid) { if ($rootScope.refreshcheck == null) { $location.path('/'); } $scope.jsPanelID = 'ciImagePanel' + '_' + windowviewid; var selectedCIImage = $scope.GetCIwindowStoreData(windowviewid, 'CIImagePath'); var selectedImageCISummary = $scope.GetCIwindowStoreData(windowviewid, 'ImageSummary'); var tittle = $scope.GetCIwindowStoreData(windowviewid, 'currentViewTitle'); var imageId = $scope.GetCIwindowStoreData(windowviewid, 'imageId'); if ($rootScope.isCallFromOtherModule) { // open JS panel for curriculum with define cornonate in CB jason $scope.jsPanelWidth = $scope.ciOpenInOtherModules.size.width;//1000; $scope.jsPanelHeight = $scope.ciOpenInOtherModules.size.height; if ($scope.ciOpenInOtherModules.size.height < 540) $scope.jsPanelHeight = 540; $scope.jsPanelLeft = $scope.ciOpenInOtherModules.position.x; if ($scope.ciOpenInOtherModules.position.x < 20) $scope.jsPanelLeft = 20; $scope.jsPanelTop = $scope.ciOpenInOtherModules.position.y; if($location.url()!= "/curriculum-builder-detail") { $scope.jsPanelLeft = 1; $scope.jsPanelTop = $rootScope.cBModulejsPanelTop(); } } else { $scope.jsPanelWidth = $(window).outerWidth() - 30; $scope.jsPanelHeight = $(window).outerHeight() - 150; $scope.jsPanelLeft = 15; $scope.jsPanelTop = 70; } $scope.jsPanelCI = $.jsPanel({ id: $scope.jsPanelID, selector: '.ciView', theme: 'success', currentController: 'CIController', parentSlug: $scope.GetCIwindowStoreData(windowviewid, 'parentSlugName'), content:'
'+ '
'+ '
'+ '
' + //'
' + '' + '
' + '

' + selectedImageCISummary + '

' + '
' + '
'+ '
', title: tittle, position: { top: $scope.jsPanelTop, left: $scope.jsPanelLeft }, size: { width: $scope.jsPanelWidth, height: $scope.jsPanelHeight }, onminimized:function (panel) { var isAutoCalled = $scope.GetCIwindowStoreData(windowviewid, 'minmaxAutoEvent'); if(!isAutoCalled) { $rootScope.UnsaveCurriculum = true; } $scope.SetCIwindowStoreData(windowviewid, 'minimised',true); $scope.SetCIwindowStoreData(windowviewid, 'maximised',false); }, onmaximized:function (panel) { var isAutoCalled = $scope.GetCIwindowStoreData(windowviewid, 'minmaxAutoEvent'); if(!isAutoCalled) { $rootScope.UnsaveCurriculum = true; } $scope.SetCIwindowStoreData(windowviewid, 'maximised',true); $scope.SetCIwindowStoreData(windowviewid, 'minimised',false); var canvasDIvHeight = $('#ciImagePanel_' + windowviewid+ " .jsPanel-content").height(); $('#canvasDivCI_' + windowviewid).css('height', canvasDIvHeight); }, onnormalized:function (panel) { var isAutoCalled = $scope.GetCIwindowStoreData(windowviewid, 'minmaxAutoEvent'); if(!isAutoCalled) { $rootScope.UnsaveCurriculum = true; } $scope.SetCIwindowStoreData(windowviewid, 'minimised',false); $scope.SetCIwindowStoreData(windowviewid, 'maximised',false); var canvasDIvHeight = $('#ciImagePanel_' + windowviewid+ " .jsPanel-content").height(); $('#canvasDivCI_' + windowviewid).css('height', canvasDIvHeight); }, resizable: { stop: function (event, ui) { var len = (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len - 1]; $scope.SetCIwindowStoreData(windowviewid, 'width', ui.size.width); $scope.SetCIwindowStoreData(windowviewid, 'height', ui.size.height); $rootScope.UnsaveCurriculum = true; var canvasDIvHeight = $('#ciImagePanel_' + windowviewid+ " .jsPanel-content").height(); //annotation lost after resize paint canvas // var canvasDIvWidth = $('#ciImagePanel_' + windowviewid+ " .jsPanel-content").width()-50; // var canvas = document.getElementById("canvasCI_" + windowviewid); // var canvasPaint = document.getElementById("canvasPaintCI_" + windowviewid); //canvas.height = canvasDIvHeight-200; // canvasPaint.height = canvasDIvHeight-200; // canvas.width = canvasDIvWidth; // canvasPaint.width = canvasDIvWidth; $('#canvasDivCI_' + windowviewid).css('height', canvasDIvHeight); } }, draggable: { stop: function( event, ui ) { var len = (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len - 1]; $scope.SetCIwindowStoreData(windowviewid, 'y', ui.position.top); $scope.SetCIwindowStoreData(windowviewid, 'x', ui.position.left); $rootScope.UnsaveCurriculum = true; } }, }); var isMaximize = $scope.GetCIwindowStoreData(windowviewid, 'maximised'); var isMinimize = $scope.GetCIwindowStoreData(windowviewid, 'minimised'); if (isMaximize) { $scope.jsPanelCI.maximize(); } else if (isMinimize) { $scope.jsPanelCI.minimize(); } else { $scope.jsPanelCI.normalize(); } // set false after initial call of min,max or normal $scope.SetCIwindowStoreData(windowviewid, 'minmaxAutoEvent', false); $scope.SetCIwindowStoreData(windowviewid, 'y', $scope.jsPanelTop); $scope.SetCIwindowStoreData(windowviewid, 'x', $scope.jsPanelLeft); $scope.SetCIwindowStoreData(windowviewid, 'width', $scope.jsPanelWidth); $scope.SetCIwindowStoreData(windowviewid, 'height', $scope.jsPanelHeight); $scope.SetCIwindowStoreData(windowviewid, 'currentSlug', 'clinical-illustrations-detail'); $timeout(function () { var canvasDIvHeight = $('#ciImagePanel_' + windowviewid+ " .jsPanel-content").height(); $('#canvasDivCI_' + windowviewid).css('height', canvasDIvHeight); if (!$rootScope.isCallFromOtherModule) { $('#CIView').css("height", $(window).outerHeight() - 65); $('#CIView').css("width", $(window).outerWidth() - 15); var canvas = document.getElementById("canvasCI_" + windowviewid); var canvasPaint = document.getElementById("canvasPaintCI_" + windowviewid); canvas.height = canvasDIvHeight-30; canvasPaint.height = canvasDIvHeight-30; var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { canvas.width = screen.width-20; canvasPaint.width = screen.width-20; } else { canvas.width = screen.width-40; canvasPaint.width = screen.width-40; } if(screen.height<400) { $('#summary_' + windowviewid).css("bottom", "-220px"); } } var openedImage = document.getElementById('ciimage_' + windowviewid ); openedImage.src = selectedCIImage; openedImage.onload = function () { if (!$rootScope.isCallFromOtherModule) { $("#ciimage_"+windowviewid).css("left", (screen.width-this.width-70)/2 + "px"); } $("#ciimage_"+windowviewid).css("visibility","visible"); var canvasZIndex = $("#canvasCI_" + windowviewid).css("z-index"); var canvasPaintZIndex = $("#canvasPaintCI_" + windowviewid).css("z-index"); if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) { canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1; $('#summary_' + windowviewid).css("z-index", canvasPaintZIndex); } else { canvasZIndex = parseInt(canvasZIndex) + 1; $('#summary_' + windowviewid).css("z-index", canvasZIndex); } $scope.JsPanelclick(windowviewid); var isTextVisible = $scope.GetCIwindowStoreData(windowviewid, 'isTextVisible'); if (isTextVisible) { $("#btnTxtOnOff_" + windowviewid).text("Text Off"); $("#sid_" + windowviewid).css("visibility", "visible"); } else { $("#btnTxtOnOff_" + windowviewid).text("Text On"); $("#sid_" + windowviewid).css("visibility", "hidden"); } if ($rootScope.isCallFromOtherModule) { var annotationData= $scope.ciOpenInOtherModules.annotationData; // load annotation if(annotationData!="" && annotationData!=undefined) { if(annotationData.shapeStates.length>0||annotationData.paintCanvasState.length>0) { //first draw shape and then store in object $rootScope.LoadCBSavedAnnotation("canvasCI_"+windowviewid,"canvasPaintCI_"+windowviewid,annotationData); } } } $scope.EnableUI(); $rootScope.CIWindowLoadComplete = true; }; $scope.PanelActivity(); },300) } $rootScope.ciAnnotationToolEvent = function (windowviewid) { $('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(255,255,255)") $('#editstylebackgroundcolor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" }); $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(0,0,0)") $('#outlineColor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" }); $('#canvasCI_'+windowviewid).css("display", "block"); $('#canvasPaintCI_'+windowviewid).css("display", "block"); } $scope.ReloadListViewImageDiv = function (id, windowviewid) { //console.log(id); $scope.idSelected = id; $scope.hiderow = true; var IllustrationData = $scope.GetCIwindowStoreData(windowviewid, 'IllustrationData'); var SelectedCIthumbImage = []; SelectedCIthumbImage = new jinqJs() .from(IllustrationData) .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; //Set the scroll position of the tablebody to show selected row. var curCIListViewScroll = $rootScope.getLocalStorageValue("CIListViewScroll"); if (typeof (curCIListViewScroll) !== "undefined" && curCIListViewScroll !== null && curCIListViewScroll !== '') { if (typeof InstallTrigger !== 'undefined') { $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue("CIListViewScroll") }); } else { $('#ListViewDiv').scrollTop($rootScope.getLocalStorageValue("CIListViewScroll")); } } }; $scope.hideListViewDiv = function () { if ($rootScope.getLocalStorageValue("currentCITabView") == 2) { localStorage.setItem("CISelectedRowId", ""); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $scope.hiderow = false; } } $scope.JsPanelclick = function (windowviewid) { //reset option list manager and annotation //call when module loaded $rootScope.resetMenuOption(); //remove pre event //$("#ciImagePanel_" + windowviewid).off("click"); $("#ciImagePanel_" + windowviewid).on('click', function (event) { //after drawing annotation click not work on iPad/Android device var pnlName = event.currentTarget.id; $rootScope.resetMenuOptionOnClick(pnlName); // store image for export while click on panel var currentViewTitle = $scope.GetCIwindowStoreData(windowviewid, 'currentViewTitle'); var imageName = $scope.GetCIwindowStoreData(windowviewid, 'imageName'); $rootScope.StoreTitleName(currentViewTitle); $rootScope.StoreOrgImageName(imageName); }); } $scope.GetTextVisiblity = function (windowviewid, btnTextValue) { var isVisible; if (btnTextValue == "Text On") { isVisible = false; $scope.SetCIwindowStoreData(windowviewid, 'isTextVisible', isVisible); } else { isVisible = true; $scope.SetCIwindowStoreData(windowviewid, 'isTextVisible', isVisible); } } $scope.RemoveJSPanel = function (panelid) { var len = (panelid).split("_").length; var windowviewid = (panelid).split("_")[len - 1]; // remove old stored data after close panel for (var index = 0 ; index < $rootScope.CIWindowData.length; index++) { if ($rootScope.CIWindowData[index].multiwinid == windowviewid) { if (index != -1) { // remove module which one is loaded $rootScope.CIWindowData.splice(index, 1); if ($('#' + panelid).html() != undefined) { $('#' + panelid).remove(); } // $rootScope.resetjsPanelTop(panelid); } } } } //Created method by Sandeep for Save JSPanel Activity on the CB module $scope.PanelActivity = function () { $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function (event) { var panelid = $(event.target).parent().parent().parent().parent().attr('id'); $scope.RemoveJSPanel(panelid); }); } }] ); function GetTextVisibityCI(event) { var scope = angular.element(document.getElementById("CIView")).scope(); // var len = (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[1]; var btnTextValue = event.target.innerText; scope.$apply(function () { scope.GetTextVisiblity(windowviewid,btnTextValue); }); }