'use strict'; AIA.controller("TileViewListController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "DataService", "ModuleService","$interval", function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, BodyRegions, BodySystems, ViewOrientations, ImageTypes, DataService, ModuleService, $interval) { $scope.AllBodyRegion = []; $scope.AllBodySystem = []; $scope.AllOrientation = []; $scope.AllImageType = []; $scope.searchAAListViewData = []; $scope.filterstring = false; $scope.isOpenBtnClicked = false; var ATLAS_ANATOMY = 'ATLAS_ANATOMY'; var CLINICAL_ILLUSTRATION = 'Clinical Illustrations'; var CLINICAL_ANIMATION = 'Clinical Animations'; $rootScope.closeBtnImgPath = "~/../content/images/speeachBubbleClose.png"; //************************************ $rootScope.listArray = []; $scope.SelectedAAthumbImage = []; $scope.SelectedAASummary = []; $scope.SelectedAAId = []; $scope.SelectedAATitle = []; // $rootScope.aaPinDataArray = []; // using at home $scope.query = { selectedbodyregion: '', selectedbodysystem: '', selectedorientation: '', selectedimagetype: '', }; $scope.showTabButton = true; $scope.isListViewDataLoaded = true; $scope.setActiveTab = function (tabToSet) { $scope.activeTab = tabToSet==undefined?1:tabToSet; localStorage.setItem("activeTab", $scope.activeTab); if ($scope.activeTab == 1) { $('#grid-view').css("display", "block"); $('#list-view').css("display", "none"); $("#demoView").remove(); } else { $('#grid-view').css("display", "none"); $('#list-view').css("display", "block"); } }; $scope.ObjectAttribute=function(windowviewid) { var windata={ 'multiwinid' : windowviewid, 'moduleName':'', 'currentViewTitle':'', 'parentSlugName':'', 'sliderPercentValue':1, 'imageId':'', 'imageName':'', 'bodySystemName':'', 'OpenItemImagePath':'', 'isBodySystemSelected':false, 'isSelectedPinBtnClickedAftrSliderCange':false, 'isHidePinBtnClicked':false, 'isShowSelectedSystemPinsClicked':false, 'isSliderChange':false, 'clickedPins':[], 'activePinArray':[], 'typeOfEvent':'', 'selectedSystemName':null, 'SelectedSystemID':0, 'aaPinData':[], 'allPinDataArray':[], 'selectedSystemPinData':[], 'AAPinTermData':[], 'pinTermData':[], 'sliderVal':100, 'speechBubbleDimaensions':[], 'isShowBodyWithCBPinData':false, 'CBselectedpinCordinate': [], 'verticalScroll': 0, 'horizontalScroll':0, 'y': 0, 'x': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': false, 'minmaxAutoEvent':true, 'id': 0, 'selectedPins': [], 'isShowSelectedPins': false, 'selectedSearchId': 0, 'isShowAllPins': false, 'canvasImageWidth': 0, 'canvasImageHeight': 0, 'navigatorImage':"", 'showHideAnnotations': 'showAnnotationText', 'annotationData':{shapeStates:[],paintCanvasState:[]}, }; return windata; } $scope.initializeAAWindowData = function(windowviewid,isOpenWithExistsModule,openPanelNo){ if (isOpenWithExistsModule || openPanelNo == 0) { if ($rootScope.AAWindowData != undefined) { $rootScope.AAWindowData.length = 0; } else { $rootScope.AAWindowData = []; } $rootScope.AAWindowData.push($scope.ObjectAttribute(windowviewid)); } else { var isNewWindow=true; for (var k = 0; k < $rootScope.AAWindowData.length; k++) { if ($rootScope.AAWindowData[k].multiwinid == windowviewid) { isNewWindow=false; break; } } if(isNewWindow) { $rootScope.AAWindowData.push($scope.ObjectAttribute(windowviewid)); } } } $scope.GetAAwindowStoreData=function(windowviewid,keyname){ for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { return $rootScope.AAWindowData[x][keyname]; } } } $scope.SetAAwindowStoreData=function(windowviewid,keyname,value){ for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { $rootScope.AAWindowData[x][keyname]=value; } } } // access from home controller //get data of AA module $rootScope.GetAAwindowData=function(windowviewid,keyname) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { return $rootScope.AAWindowData[x][keyname]; } } } // access from home controller $rootScope.SetAAwindowData=function(windowviewid,keyname,data) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { $rootScope.AAWindowData[x][keyname]=data; } } } $scope.DisableUI = function () { var daImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < daImagePanelConetent.length; i++) { daImagePanelConetent[i].style.pointerEvents = "none"; daImagePanelConetent[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 daImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < daImagePanelConetent.length; i++) { daImagePanelConetent[i].style.pointerEvents = "auto"; daImagePanelConetent[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.loadForModuleById = function (moduleId) { $scope.DisableUI(); $rootScope.isCallFromOtherModule = undefined; $rootScope.MULTI_VIEW_ID += 1 // store exist module in module service var ExistData = ModuleService.getModuleData("ATLAS_ANATOMY"); if (ExistData != undefined && ExistData.length > 0) { // clear all module data before open new module in cb ModuleService.ClearWinDataByModule(ExistData.mType); } var newWindowData = { "mType": 'ATLAS_ANATOMY', }; ModuleService.setModuleData(newWindowData, 0); // close/remove prev panel when in minimised mode if($rootScope.AAWindowData!=undefined) { if($rootScope.AAWindowData.length>0) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ var winid=$rootScope.AAWindowData[x].multiwinid; if ($('#AAImagePanel_' + winid).html() != undefined) { $('#AAImagePanel_' + winid).remove(); } } $rootScope.AAWindowData=[]; } } $scope.initializeAAWindowData($rootScope.MULTI_VIEW_ID,true,undefined); $rootScope.openModules.push({ "ModuleId": 2 }); if ($rootScope.refreshcheck == null) { $location.path('/'); } var curtab = $rootScope.getLocalStorageValue("activeTab"); $scope.setActiveTab(curtab) console.log('loadForModuleById is called') $scope.SetAAwindowStoreData($rootScope.MULTI_VIEW_ID,'moduleName',"ATLAS_ANATOMY"); $rootScope.currentActiveModuleTitle = "ATLAS_ANATOMY"; $scope.AllBodyRegion = BodyRegions; $scope.AllBodySystem = BodySystems; $scope.AllOrientation = ViewOrientations; $scope.AllImageType = ImageTypes; if (localStorage.getItem("CurrentBodyRegion") != '') { $("#region option[value='" + localStorage.getItem('CurrentBodyRegion') + "']").prop('selected', true); } if (localStorage.getItem("CurrentBodySystem") != '') { $("#system option[value='" + localStorage.getItem('CurrentBodySystem') + "']").prop('selected', true); } if (localStorage.getItem("CurrentOrientation") != '') { $("#orientation option[value='" + localStorage.getItem('CurrentOrientation') + "']").prop('selected', true); } if (localStorage.getItem("CurrentImageType") != '') { $("#Type option[value='" + localStorage.getItem('CurrentImageType') + "']").prop('selected', true); } $scope.query.selectedbodyregion = localStorage.getItem('CurrentBodyRegion'); $scope.query.selectedbodysystem = localStorage.getItem('CurrentBodySystem'); $scope.query.selectedorientation = localStorage.getItem('CurrentOrientation'); $scope.query.selectedimagetype = localStorage.getItem('CurrentImageType'); $scope.FilterByImage(1, $scope.query,$rootScope.MULTI_VIEW_ID); setTimeout(function () { if ($('#grid-view').css("display") == "block") { if ($rootScope.getLocalStorageValue('AAGridViewHighlightThumbnail') !== null) { $('#' + $rootScope.getLocalStorageValue("AAGridViewHighlightThumbnail")).find('.thumbnail').addClass('HightLightThumbnail'); } if ($rootScope.getLocalStorageValue('AAGridViewScroll') !== null && $location.url() == "/tile-view-list") { $('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AAGridViewScroll') }, 'slow'); } } if ($('#list-view').css("display") == "block") { var AAListViewScroll = $rootScope.getLocalStorageValue("AAListViewScroll"); if (typeof (AAListViewScroll) !== "undefined" && AAListViewScroll !== null && AAListViewScroll !== '' && $location.url() == "/tile-view-list") { if (typeof InstallTrigger !== 'undefined') { $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AAListViewScroll') }, 'slow'); } else { $('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue('AAListViewScroll') }, 'slow'); } $("#list-view table tbody tr").removeClass("active"); $("#list-view table tbody #" + $rootScope.getLocalStorageValue("listViewSelectedID")).addClass("active"); } } $scope.EnableUI(); }, 100); // $('#list-view').css('display', 'none'); } $scope.openModuleItemView = function ($event) { var windowviewid = $rootScope.MULTI_VIEW_ID; $rootScope.MenuModuleName = "AA"; //0. Get selected Image Id if ($scope.isListViewButtonClicked == true) { if ($scope.isOpenBtnClicked == true) { var moduleItemDataToBeSaved = $("#demoText").text().trim(); var moduleItemDataToBeSavedID = $event.target.id; $scope.isOpenBtnClicked = false; } else { var moduleItemDataToBeSavedID = $event.currentTarget.id; localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID); var moduleItemDataToBeSaved = $("#list-view table tbody #" + moduleItemDataToBeSavedID).find('td:eq(0)').text().trim(); } } else { var moduleItemDataToBeSavedID = $event.currentTarget.id; localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID); var moduleItemDataToBeSaved = $("#list-view table tbody #" + moduleItemDataToBeSavedID).find('td:eq(0)').text().trim(); $scope.isListViewButtonClicked = false; } // open module bu openresource var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource'); if (isopenResourceRequest == "true") { //set default module data var AAopenData = { "id": moduleItemDataToBeSavedID, "mType": 'ATLAS_ANATOMY', "showAllPins":true, "windowTitle": moduleItemDataToBeSaved, "scaleIndex":100, "size": { height: 600, width: 900 }, "position": { x: 300, y: 110 } }; window.parent.AIAModuleOpenResourceInfo(AAopenData); window.parent.closeIFrame(); } else { //1.Filter selected module ietem data and get the pushed opened moduile array object var OpenedTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData); //2. Pick the image name to create a source to open $scope.SetAAwindowStoreData(windowviewid, 'imageId', OpenedTileData[0]); $scope.SetAAwindowStoreData(windowviewid, 'imageName', OpenedTileData[3]); var imageName = OpenedTileData[3]; $scope.SetAAwindowStoreData(windowviewid, 'bodySystemName', OpenedTileData[2]); var OpenItemImagePath = "../../../content/images/aa/images/" + OpenedTileData[3]; $scope.SetAAwindowStoreData(windowviewid, 'OpenItemImagePath', OpenItemImagePath); $rootScope.listArray.push({ "imageName": OpenItemImagePath, "text": moduleItemDataToBeSaved }); //3. set opened module item ti localStorage.setItem("currentViewTitle", OpenedTileData[6]); if ($('#grid-view').css("display") == "block") { localStorage.setItem("AAGridViewScroll", $($window).scrollTop()); localStorage.setItem("AAGridViewHighlightThumbnail", $(event.target).parent().parent().parent().attr('id')); } $scope.SetAAwindowStoreData(windowviewid, 'currentViewTitle', OpenedTileData[6]); // store image for export var tittle = $rootScope.getLocalStorageValue("currentViewTitle"); $rootScope.StoreTitleName(tittle); $rootScope.StoreOrgImageName(imageName); //3. Navigate to the Module-item-view var u = $location.url(); $location.url('/module-item-view'); } } $scope.openListViewModuleItem = function (event) { var windowviewid= $rootScope.MULTI_VIEW_ID; $("#demoView").remove(); var moduleItemDataToBeSavedID = event.currentTarget.id; $("#list-view table tbody tr").removeClass("active"); localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID); $("#list-view table tbody #" + moduleItemDataToBeSavedID).addClass("active"); localStorage.setItem("AAListViewScroll", $("#list-view table tbody").scrollTop()); var moduleItemDataToBeSaved = $("#list-view table tbody #" + moduleItemDataToBeSavedID).find('td:eq(0)').text().trim(); var OpenedTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData); var OpenItemImagePath = "../../../content/images/aa/images/" +OpenedTileData[3]; $scope.SetAAwindowStoreData(windowviewid,'OpenItemImagePath',OpenItemImagePath); $rootScope.listArray.push({ "imageName": OpenItemImagePath, "text": moduleItemDataToBeSaved }); $("#viewList").append("
" + moduleItemDataToBeSaved + "
Open
"); } $rootScope.openAAModuleItemMain = function () { $scope.DisableUI(); if ($rootScope.isCallFromOtherModule) { $scope.AAModuleData = ModuleService.getModuleData("ATLAS_ANATOMY"); $scope.readyToLoad=true; $rootScope.AAWindowLoadComplete = false; $scope.wincount=1; var winlen=$scope.AAModuleData.length; var timeint = null; timeint = $interval(function() { if($scope.readyToLoad==true) { var windata = $scope.AAModuleData[$scope.wincount - 1]; $scope.openModuleItem(windata); } $scope.readyToLoad=false; if($scope.wincount 0) { $scope.SetAAwindowStoreData(windowviewid,'imageId',selectedTileData[0]._ImageId); var imageName = selectedTileData[0]._ImageName; $scope.SetAAwindowStoreData(windowviewid, 'imageName', imageName); $scope.SetAAwindowStoreData(windowviewid,'bodySystemName',selectedTileData[0]._BodySystem); var OpenItemImagePath = "../../../content/images/aa/images/" + imageName; $scope.SetAAwindowStoreData(windowviewid,'OpenItemImagePath',OpenItemImagePath); $scope.listArray.push({ "imageName": OpenItemImagePath, "text": anatomyTitle }); // store image for export var tittle = $rootScope.getLocalStorageValue("currentViewTitle"); $rootScope.StoreTitleName(tittle); $rootScope.StoreOrgImageName(imageName); //3. set opened module item ti $scope.loadAAIllustration(windowviewid); } }) } else { $scope.SetAAwindowStoreData($rootScope.MULTI_VIEW_ID,'parentSlugName','tile-view-list'); $scope.loadAAIllustration($rootScope.MULTI_VIEW_ID); } } $scope.loadAAIllustration = function (windowviewid) { //0.4 for Opening module item, load it into image $scope.DisableUI(); if ($rootScope.refreshcheck == null) { $location.path('/'); } var jsContentURL; // var moduleItemViewDivId; var moduleName= $scope.GetAAwindowStoreData(windowviewid,'moduleName'); //1. create a jsPanel and load the module item view if (moduleName == ATLAS_ANATOMY) { jsContentURL = 'app/views/aa/atlas-anatomy-detail.html'; // moduleItemViewDivId = 'aaDetailPageDiv'; $scope.jsPanelID = 'AAImagePanel' + '_' + windowviewid; } else if (moduleName == CLINICAL_ANIMATION) { //to do, in next phase of project } else if (moduleName == CLINICAL_ILLUSTRATION) { //to do, in next phase of project } var currentViewTitle = $scope.GetAAwindowStoreData(windowviewid,'currentViewTitle'); if ($rootScope.isCallFromOtherModule) { // open JS panel for curriculum with define cornonate in CB jason $scope.jsPanelWidth = $scope.aaOpenInOtherModules.size.width;//1000; $scope.jsPanelHeight = $scope.aaOpenInOtherModules.size.height; if($scope.aaOpenInOtherModules.size.height<420) $scope.jsPanelHeight = 420; $scope.jsPanelLeft = $scope.aaOpenInOtherModules.position.x; if ($scope.aaOpenInOtherModules.position.x < 20) $scope.jsPanelLeft = 20; $scope.jsPanelTop = $scope.aaOpenInOtherModules.position.y; if($location.url()!= "/curriculum-builder-detail") { $scope.jsPanelLeft = 1; $scope.jsPanelTop = $rootScope.cBModulejsPanelTop(); } } else { $scope.jsPanelWidth = $(window).outerWidth() - 20; $scope.jsPanelHeight = $(window).outerHeight() - 125; $scope.jsPanelLeft = 1; $scope.jsPanelTop = 70; } //1. create a jsPanel and load the module item view if (moduleName == ATLAS_ANATOMY) { $scope.jsPanelAA = $.jsPanel({ id: $scope.jsPanelID, selector: '.aaBodyView', theme: 'success', currentController: 'TileViewListController', parentSlug: $scope.GetAAwindowStoreData(windowviewid,'parentSlugName'), ajax: { url: jsContentURL }, title: currentViewTitle, position: { top: $scope.jsPanelTop, left: $scope.jsPanelLeft, }, size: { width: $scope.jsPanelWidth, height: $scope.jsPanelHeight }, onminimized:function (panel) { var isAutoCalled = $scope.GetAAwindowStoreData(windowviewid, 'minmaxAutoEvent'); if(!isAutoCalled) { $rootScope.UnsaveCurriculum = true; } $scope.SetAAwindowStoreData(windowviewid, 'minimised',true); $scope.SetAAwindowStoreData(windowviewid, 'maximised',false); }, onmaximized:function (panel) { var isAutoCalled = $scope.GetAAwindowStoreData(windowviewid, 'minmaxAutoEvent'); if(!isAutoCalled) { $rootScope.UnsaveCurriculum = true; } $scope.SetAAwindowStoreData(windowviewid, 'maximised',true); $scope.SetAAwindowStoreData(windowviewid, 'minimised',false); }, onnormalized:function (panel) { var isAutoCalled = $scope.GetAAwindowStoreData(windowviewid, 'minmaxAutoEvent'); if(!isAutoCalled) { $rootScope.UnsaveCurriculum = true; } $scope.SetAAwindowStoreData(windowviewid, 'minimised',false); $scope.SetAAwindowStoreData(windowviewid, 'maximised',false); }, resizable: { stop: function (event, ui) { var len = (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len - 1]; $scope.SetAAwindowStoreData(windowviewid, 'width', ui.size.width); $scope.SetAAwindowStoreData(windowviewid, 'height', ui.size.height); $rootScope.UnsaveCurriculum = true; var canvasDIvHeight = $('#AAImagePanel_' + windowviewid+ " .jsPanel-content").height()-70; $('#canvasAADiv_' + 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.SetAAwindowStoreData(windowviewid, 'y', ui.position.top); $scope.SetAAwindowStoreData(windowviewid, 'x', ui.position.left); $rootScope.UnsaveCurriculum = true; } }, }); //0.3 var aaViewElement = angular.element(document.getElementById("aaBodyView")); //Perform Activity as per SaveCb JSPanel var isMaximize = $scope.GetAAwindowStoreData(windowviewid, 'maximised'); var isMinimize = $scope.GetAAwindowStoreData(windowviewid, 'minimised'); if (isMaximize) { $scope.jsPanelAA.maximize('auto'); } else if (isMinimize) { $scope.jsPanelAA.minimize('auto'); } else { $scope.jsPanelAA.normalize('auto'); } // set false after initial call of min,max or normal $scope.SetAAwindowStoreData(windowviewid, 'minmaxAutoEvent', false); $scope.SetAAwindowStoreData(windowviewid, 'y', $scope.jsPanelTop); $scope.SetAAwindowStoreData(windowviewid, 'x', $scope.jsPanelLeft); $scope.SetAAwindowStoreData(windowviewid, 'width', $scope.jsPanelWidth); $scope.SetAAwindowStoreData(windowviewid, 'height', $scope.jsPanelHeight); $timeout(function () { if (document.getElementById('aaBodyView') != null) { $compile(aaViewElement.contents())($scope); $scope.setControlsIDs(windowviewid); var timeintval = null; timeintval = $interval(function () { var bodySystemListObj = document.getElementById("bodySystemList_" + windowviewid); var len = bodySystemListObj!=null?(bodySystemListObj.id).split("_").length:0; if (len>1) { $scope.stopIntervalLoader(); //wait until DOM element load of AA $scope.loadAAModule(windowviewid); } else { $scope.setControlsIDs(windowviewid); console.log("waiting for loading module"); } }, 200); $scope.stopIntervalLoader = function () { if (angular.isDefined(timeintval)) { $interval.cancel(timeintval); timeintval = undefined; } }; } }, 500); } } $scope.loadAAModule = function (windowviewid) { if ($rootScope.isCallFromOtherModule) { var canvasDIvHeight = parseInt($('#AAImagePanel_' + windowviewid).outerHeight()) - 100; } else { var canvasDIvHeight = parseInt($('#AAImagePanel_' + windowviewid).outerHeight()) - 90; $('#aaBodyView').css("height", $(window).outerHeight() - 65); $('#aaBodyView').css("width", $(window).outerWidth() - 15); } $('#canvasAADiv_' + windowviewid).css('height', canvasDIvHeight); $('.canvasDivClass').css("height", canvasDIvHeight); $scope.convertToZoomValue(windowviewid); var OpenItemImagePath= $scope.GetAAwindowStoreData(windowviewid,'OpenItemImagePath'); var openedImage = document.getElementById("modItemImage_"+windowviewid); openedImage.src = OpenItemImagePath; openedImage.onload = function () { $scope.SetAAwindowStoreData(windowviewid, 'canvasImageWidth', this.width); $scope.SetAAwindowStoreData(windowviewid, 'canvasImageHeight', this.height); var zoomValue = $scope.GetAAwindowStoreData(windowviewid, 'sliderVal'); var relativeWidth = ( this.width)*(zoomValue/100); var relativeHeight = (this.height)*(zoomValue/100); $scope.SetAAwindowStoreData(windowviewid,'sliderPercentValue',(zoomValue/100)); $("#modItemImage_"+windowviewid).css("width", relativeWidth + "px"); $("#modItemImage_"+windowviewid).css("height", relativeHeight + "px"); //0.5 create canvas on the top of image. var canvas = document.createElement('canvas'); canvas.id = 'aaDetailViewCanvas_'+windowviewid; canvas.className = '.aaCanvas' canvas.height = parseInt(relativeHeight + 10); canvas.width = parseInt(relativeWidth + 10); canvas.style.left = '0px'; canvas.style.top = '0px'; canvas.style.position = "absolute"; canvas.style.zIndex = 12002; $("#canvasAADiv_" + windowviewid).append(canvas); $timeout(function () { $scope.loadAllPinFirstTime(windowviewid); //call time interval function until load pin data var timeintval = null; timeintval = $interval(function () { var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); if (aaPinData.length>0) { $scope.stopIntervalAA(); $scope.showAllPins(windowviewid); $scope.Setslider(windowviewid); //7. Highlight all system body list in left side $scope.highlightBodySystemList(windowviewid); $scope.loadbtnNavigator(windowviewid); $scope.JsPanelclick(windowviewid); if ($rootScope.isCallFromOtherModule) { $scope.loadAAonCBData(windowviewid); //$rootScope.ShowAnnotationWindow(); //show tool if need var annotationData= $scope.aaOpenInOtherModules.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("canvasAA_"+windowviewid,"canvasPaintAA_"+windowviewid,annotationData); } } } } else { console.log("waiting for pin Data"); } }, 100); $scope.stopIntervalAA = function () { if (angular.isDefined(timeintval)) { $interval.cancel(timeintval); timeintval = undefined; } }; },500); } openedImage.onerror = loadFailure; // openedImage.src = OpenItemImagePath; //Calling methode for save Js Panel Activity for SaveCB $scope.PanelActivity(); } $scope.convertToZoomValue = function (windowviewid) { var zoomValue = $scope.GetAAwindowStoreData(windowviewid, 'sliderVal'); switch (zoomValue) { case 0: //$scope.zoomLevel = 100; $scope.SetAAwindowStoreData(windowviewid,'sliderVal',100); break; case 1: //$scope.zoomLevel = 85; $scope.SetAAwindowStoreData(windowviewid,'sliderVal',85); break; //case 2: // $scope.zoomLevel = ; // break; case 3: //$scope.zoomLevel = 55; $scope.SetAAwindowStoreData(windowviewid,'sliderVal',55); break; //case 4: // $scope.zoomLevel = 55; // break; //case 5: // $scope.zoomLevel = 40; // break; //case 6: // $scope.zoomLevel = 25; // break; default: // $scope.zoomLevel = zoomValue; $scope.SetAAwindowStoreData(windowviewid,'sliderVal',zoomValue); } } $scope.Setslider = function (windowviewid) { var zoomLevel = $scope.GetAAwindowStoreData(windowviewid, 'sliderVal'); $("#Vslider_" + windowviewid).slider({ min: 25, max: 100, value: zoomLevel, range: "min", orientation: "vertical", slide: function (event, ui) { // work on touch screen device var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { var targetid = event.target.id; var len= (targetid).split("_").length; var windviewid = (targetid).split("_")[len-1]; changeThumbnailSize(event, ui.value, windviewid); } } , change: function (event, ui) { var targetid = event.target.id; var len= (targetid).split("_").length; var windviewid = (targetid).split("_")[len-1]; changeThumbnailSize(event, ui.value, windviewid); } // , // stop: function (event, ui) { // //work on click when slide no is not in below case // if (ui.value != 25 || ui.value != 40 || ui.value != 55 || ui.value != 70 || ui.value != 85 || ui.value != 100) { // var targetid = event.target.id; // var len= (targetid).split("_").length; // var windviewid = (targetid).split("_")[len-1]; // changeThumbnailSize(event, ui.value, windviewid); // } // } }) .slider("pips", { rest: "label", step: "15" }); } $scope.setControlsIDs = function (windowviewid) { $("#canvasDiv").attr("id", "canvasAADiv_" + windowviewid); $("#canvas").attr("id", "canvasAA_" + windowviewid); $("#canvasPaint").attr("id", "canvasPaintAA_" + windowviewid); $("#Vslider").attr("id", "Vslider_" + windowviewid); $("#selectedPin").attr("id", "selectedPin_" + windowviewid); $("#hidePinBtn").attr("id", "hidePinBtn_" + windowviewid); $("#allPinBtn").attr("id", "allPinBtn_" + windowviewid); $("#bodySystemList").attr("id", "bodySystemList_" + windowviewid); $("#dropdownMenu221").attr("id", "dropdownMenu221_" + windowviewid); $("#sideBarToggle").attr("id", "sideBarToggle_" + windowviewid); $("#navimg").attr("id", "navimg_" + windowviewid); $("#navigatorBtn").attr("id", "navigatorBtn_" + windowviewid); $("#navigatorDiv").attr("id", "navigatorDiv_" + windowviewid); $("#comment-box").attr("id", "comment-box_" + windowviewid); $("#selectedTermName").attr("id", "selectedTermName_" + windowviewid); $("#termlistfilter").attr("id", "termlistfilter_" + windowviewid); $("#btnSearchAA").attr("id", "btnSearchAA_" + windowviewid); $("#modItemImage").attr("id", "modItemImage_" + windowviewid); } $scope.loadbtnNavigator = function (windowviewid) { var navigatorimage = $scope.GetAAwindowStoreData(windowviewid,'navigatorImage'); if (navigatorimage != undefined && navigatorimage != "") { document.getElementById("navimg_" + windowviewid).src = '~/../content/images/aa/images/navigator/' + navigatorimage; } else { $('#navimg_' + windowviewid).css('visibility', 'hidden'); $('#navigatorBtn_' + windowviewid).css('visibility', 'hidden'); $('#navigatorDiv_' + windowviewid).css('visibility', 'hidden'); } $("#navigatorBtn_" + windowviewid).on('click', function () { $("#navigatorDiv_" + windowviewid).toggle(); }); } $scope.JsPanelclick = function (windowviewid) { //reset option list manager and annotation //call when module loaded $rootScope.resetMenuOption(); //remove pre event $("#AAImagePanel_" + windowviewid).off("click touchstart"); $("#AAImagePanel_" + windowviewid).on('click touchstart', function (event) { //after drawing annotation click not work on iPad/Android device var pnlName=event.currentTarget.id; $rootScope.resetMenuOptionOnClick(pnlName); var titlt = $("#AAImagePanel_" + windowviewid).childNodes; // store image for export while click on panel var currentViewTitle = $scope.GetAAwindowStoreData(windowviewid, 'currentViewTitle'); var imageName = $scope.GetAAwindowStoreData(windowviewid, 'imageName'); $rootScope.StoreTitleName(currentViewTitle); $rootScope.StoreOrgImageName(imageName); }); } $scope.setPreClickBtnCss = function (windowviewid) { if ($scope.aaOpenInOtherModules.showAllPins != undefined && $scope.aaOpenInOtherModules.showAllPins) { $scope.ToolBoxStyle("ShowAllPin", windowviewid); } else if ($scope.aaOpenInOtherModules.showSelectedPins != undefined && $scope.aaOpenInOtherModules.showSelectedPins) { $scope.ToolBoxStyle("ShowSelectedPin", windowviewid); } else if ($scope.aaOpenInOtherModules.hideAllPins != undefined && $scope.aaOpenInOtherModules.hideAllPins) { $scope.ToolBoxStyle("HidePin", windowviewid); } } function changeThumbnailSize(event, value,windowviewid) { var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { $scope.SetAAwindowStoreData(windowviewid,'sliderVal',value) scope.removeSpeechBubble(windowviewid); var relativeWidth = 0; var relativeHeight = 0; // if (value == 25 || value == 40 || value == 55 || value == 70 || value == 85 || value == 100) { $("#listManager").css("display", "none"); $("#optionsListManagerTab").removeClass("active"); $rootScope.UnsaveCurriculum = true; var ViewImageWidth = $scope.GetAAwindowStoreData(windowviewid, 'canvasImageWidth'); var ViewImageHeight = $scope.GetAAwindowStoreData(windowviewid, 'canvasImageHeight'); relativeWidth = (ViewImageWidth)*(value/100); relativeHeight = (ViewImageHeight)*(value/100); $scope.SetAAwindowStoreData(windowviewid,'sliderPercentValue',(value/100)); $("#modItemImage_"+windowviewid).css("width", relativeWidth + "px"); $("#modItemImage_"+windowviewid).css("height", relativeHeight + "px"); //get last zindex var zindex= $("#aaDetailViewCanvas_"+windowviewid).css("z-index"); $("#aaDetailViewCanvas_"+windowviewid).remove(); //0.5 create canvas on the top of image so that I can draw a line over the canvas. var canvas = document.createElement('canvas'); canvas.id = "aaDetailViewCanvas_"+windowviewid; canvas.className = 'aaCanvas'; canvas.height = relativeHeight + 10; canvas.width = relativeWidth + 10; canvas.style.left = '0px'; canvas.style.top = '0px'; canvas.style.position = "absolute"; canvas.style.zIndex = zindex; $("#canvasAADiv_" + windowviewid).append(canvas); $scope.SetAAwindowStoreData(windowviewid,'isSliderChange',true); var toolbtnID = ''; if ($("#allPinBtn_" + windowviewid).hasClass("btn-primary")) { toolbtnID="allPinBtn_"+windowviewid; } else if ($("#selectedPin_" + windowviewid).hasClass("btn-primary")) { toolbtnID="selectedPin_"+windowviewid; } else if ($("#hidePinBtn_" + windowviewid).hasClass("btn-primary")) { toolbtnID="hidePinBtn_"+windowviewid; } $scope.SetAAwindowStoreData(windowviewid,'isSelectedPinBtnClickedAftrSliderCange',true); switch (toolbtnID) { case "hidePinBtn_"+windowviewid: break; case "allPinBtn_"+windowviewid: if ($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("id") != undefined) { if ($rootScope.isCallFromOtherModule != undefined && $rootScope.isCallFromOtherModule == true) { var SelectedSystemID = $scope.GetAAwindowStoreData(windowviewid, 'SelectedSystemID'); if (SelectedSystemID != undefined) { scope.showSelectedSystemPins(SelectedSystemID, windowviewid); } else { scope.showSelectedSystemPins($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("id"), windowviewid); } } else { scope.showSelectedSystemPins($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("id"), windowviewid); } } else { scope.showAllPins(windowviewid); } break; case "selectedPin_"+windowviewid: scope.showAllPins(windowviewid,true); break; } // } }); } $scope.highlightBodySystemList = function (windowviewid) { var SelectedSystemID= $scope.GetAAwindowStoreData(windowviewid,'SelectedSystemID'); var bodySystemName= $scope.GetAAwindowStoreData(windowviewid,'bodySystemName'); var bodySystemNames = bodySystemName.trim().split(/\s*,\s*/); var bodySystemListObj = document.getElementById("bodySystemList_" + windowviewid).getElementsByTagName("a"); var bodySystemListlength = bodySystemListObj.length; for (var i = 0; i < bodySystemListlength; i++) { //var boldTag = lis[i]; for (var j = 0; j < bodySystemNames.length; j++) { if ((bodySystemListObj[i].innerHTML) == (bodySystemNames[j])) { $(bodySystemListObj[i].parentElement).removeClass("disabledSelectedSystem"); } $(bodySystemListObj[i].parentElement).removeClass("activeAASystemSelect"); //add class for selected element if (i == SelectedSystemID) { $(bodySystemListObj[i].parentElement).addClass("activeAASystemSelect"); } } } } function loadFailure() { console.log('unable to load opened module ietem'); return true; } angular.element(document).ready(function (e) { $("#" + $scope.jsPanelID).resize(function () { $("#canvasDiv").scrollLeft($rootScope.CanvasDivLeftPosition); $("#canvasDiv").scrollTop($rootScope.CanvasDivTopPosition); }); }) // curriculum function to load data $scope.loadAAonCBData = function (windowviewid) { $scope.SetAAwindowStoreData(windowviewid,'isShowBodyWithCBPinData',true); var CBselectedpinCordinate=$scope.GetAAwindowStoreData(windowviewid,'CBselectedpinCordinate'); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); var selectedPins=[]; if ($scope.aaOpenInOtherModules.selectedPins != undefined) { for (var i = 0; i < $scope.aaOpenInOtherModules.selectedPins.length; i++) { selectedPins = $scope.GetAAwindowStoreData(windowviewid, 'selectedPins'); var pinid = $scope.aaOpenInOtherModules.selectedPins[i]; selectedPins.push(pinid); var pinvalue = 'PinArc_' + pinid; var isFound = jQuery.inArray(pinvalue, activePinArray) if (isFound == -1) { activePinArray.push(pinvalue); clickedPins.push({ 'id': pinid }); } } if (selectedPins != undefined) { $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', selectedPins); } } if ($scope.aaOpenInOtherModules.selectedCallouts != undefined) { for (var i = 0; i < $scope.aaOpenInOtherModules.selectedCallouts.length; i++) { var pinId = $scope.aaOpenInOtherModules.selectedCallouts[i].pinId; if (pinId == undefined) { CBselectedpinCordinate.push( { "hy": $scope.aaOpenInOtherModules.selectedCallouts[i].hy, "ly": $scope.aaOpenInOtherModules.selectedCallouts[i].ly, "hx": $scope.aaOpenInOtherModules.selectedCallouts[i].hx, "lx": $scope.aaOpenInOtherModules.selectedCallouts[i].lx, "pinId": undefined }); } else { CBselectedpinCordinate.push( { "hy": $scope.aaOpenInOtherModules.selectedCallouts[i].hy, "ly": $scope.aaOpenInOtherModules.selectedCallouts[i].ly, "hx": $scope.aaOpenInOtherModules.selectedCallouts[i].hx, "lx": $scope.aaOpenInOtherModules.selectedCallouts[i].lx, "pinId": $scope.aaOpenInOtherModules.selectedCallouts[i].pinId }); } } } if ($scope.aaOpenInOtherModules.showSelectedPins != undefined && $scope.aaOpenInOtherModules.showSelectedPins) { //show selected pin $scope.activePinOnLayerChange(windowviewid); $scope.showSelectedPins(windowviewid); $timeout(function () { $scope.ShowCBAnnotation(windowviewid); }, 1000); } else if ($scope.aaOpenInOtherModules.showAllPins != undefined && $scope.aaOpenInOtherModules.showAllPins) { //Show all pins $scope.activePinOnLayerChange(windowviewid); $scope.showAllPinsAfterHide(windowviewid); $timeout(function () { $scope.ShowCBAnnotation(windowviewid); }, 500); } else if ($scope.aaOpenInOtherModules.hideAllPins != undefined && $scope.aaOpenInOtherModules.hideAllPins) { //hide all pins $rootScope.hidePins(windowviewid); $timeout(function () { $scope.ShowCBAnnotation(windowviewid); $scope.hideSpeechBubble(windowviewid); }, 500); } } $scope.ShowCBAnnotation=function(windowviewid) { var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); if (CBselectedpinCordinate.length >0) { var pinId = CBselectedpinCordinate[0].pinId; if (pinId == undefined) { angular.forEach(clickedPins, function (value, key) { if (aaPinData != null && aaPinData.length > 0) { var pinData = new jinqJs() .from(aaPinData) .where("_PinId == " + value.id) .select(); var headX = (parseInt(pinData[0]._HeadX)); var headY = (parseInt(pinData[0]._HeadY)); var pinId = (parseInt(pinData[0]._PinId)); // match pin data by hx and hy CB cordinate to show annotation var matchdata = new jinqJs() .from(CBselectedpinCordinate) .where("hx == " + headX, "hy == " + headY) .select(); if (matchdata.length > 0) { var updatedata = new jinqJs() .from(CBselectedpinCordinate) .update(function (coll, index) { coll[index].pinId = pinId; }) .at("hx == " + headX, "hy == " + headY); $scope.MultiLanguageAnnationArray = []; $scope.GetAnnotationBasedOnActualTermNo(pinData[0]._TermId, windowviewid); $scope.createSpeechBubble(parseInt(headX) + 10, parseInt(headY) + 10, matchdata[0].lx, matchdata[0].ly, pinId, false, false, false, windowviewid); } } }); } else { angular.forEach(clickedPins, function (value, key) { if (aaPinData != null && aaPinData.length > 0) { var pinData = new jinqJs() .from(aaPinData) .where("_PinId == " + value.id) .select(); var headX = (parseInt(pinData[0]._HeadX)); var headY = (parseInt(pinData[0]._HeadY)); var pinId = (parseInt(pinData[0]._PinId)); // match pin data by hx and hy CB cordinate to show annotation var matchdata = new jinqJs() .from(CBselectedpinCordinate) .where("pinId == " + pinId) .select(); if (matchdata.length > 0) { $scope.MultiLanguageAnnationArray = []; $scope.GetAnnotationBasedOnActualTermNo(pinData[0]._TermId, windowviewid); $scope.createSpeechBubble(parseInt(headX) + 10, parseInt(headY) + 10, matchdata[0].lx, matchdata[0].ly, pinId, false, false, false, windowviewid); } } }); } } $scope.SetAAwindowStoreData(windowviewid,'isShowBodyWithCBPinData',false); $rootScope.AAWindowLoadComplete=true; } $scope.ToolBoxStyle=function(Notification,windowviewid) { if(Notification=="ShowSelectedPin") { $("#selectedPin_" + windowviewid).removeClass("btn-black"); $("#selectedPin_" + windowviewid).addClass("btn-primary"); if (!$("#hidePinBtn_" + windowviewid).hasClass("btn-black")) { $("#hidePinBtn_" + windowviewid).addClass("btn-black"); } if ($("#hidePinBtn_" + windowviewid).hasClass("btn-primary")) { $("#hidePinBtn_" + windowviewid).removeClass("btn-primary"); } if (!$("#allPinBtn_" + windowviewid).hasClass("btn-black")) { $("#allPinBtn_" + windowviewid).addClass("btn-black"); } if ($("#allPinBtn_" + windowviewid).hasClass("btn-primary")) { $("#allPinBtn_" + windowviewid).removeClass("btn-primary"); } if (!$("#dropdownMenu221_" + windowviewid).hasClass("aaSystemDisable")) { $("#dropdownMenu221_" + windowviewid).addClass("aaSystemDisable"); } } else if(Notification=="ShowAllPin") { $("#allPinBtn_" + windowviewid).removeClass("btn-black"); $("#allPinBtn_" + windowviewid).addClass("btn-primary"); if (!$("#hidePinBtn_" + windowviewid).hasClass("btn-black")) { $("#hidePinBtn_" + windowviewid).addClass("btn-black"); } if ($("#hidePinBtn_" + windowviewid).hasClass("btn-primary")) { $("#hidePinBtn_" + windowviewid).removeClass("btn-primary"); } if (!$("#selectedPin_" + windowviewid).hasClass("btn-black")) { $("#selectedPin_" + windowviewid).addClass("btn-black"); } if ($("#selectedPin_" + windowviewid).hasClass("btn-primary")) { $("#selectedPin_" + windowviewid).removeClass("btn-primary"); } $("#dropdownMenu221_" + windowviewid).removeClass("aaSystemDisable"); } else if(Notification=="HidePin") { $("#hidePinBtn_" + windowviewid).removeClass("btn-black"); $("#hidePinBtn_" + windowviewid).addClass("btn-primary"); if (!$("#allPinBtn_" + windowviewid).hasClass("btn-black")) { $("#allPinBtn_" + windowviewid).addClass("btn-black"); } if ($("#allPinBtn_" + windowviewid).hasClass("btn-primary")) { $("#allPinBtn_" + windowviewid).removeClass("btn-primary"); } if (!$("#selectedPin_" + windowviewid).hasClass("btn-black")) { $("#selectedPin_" + windowviewid).addClass("btn-black"); } if ($("#selectedPin_" + windowviewid).hasClass("btn-primary")) { $("#selectedPin_" + windowviewid).removeClass("btn-primary"); } if (!$("#dropdownMenu221_" + windowviewid).hasClass("aaSystemDisable")) { $("#dropdownMenu221_" + windowviewid).addClass("aaSystemDisable"); } } } $scope.showAllPins = function (windowviewid,islayerChange) { $scope.SetAAwindowStoreData(windowviewid,'allPinDataArray',[]); var isSliderChange=$scope.GetAAwindowStoreData(windowviewid,'isSliderChange'); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); if (aaPinData != null && aaPinData.length > 0) { var allPinDataArray=$scope.GetAAwindowStoreData(windowviewid,'allPinDataArray'); var selectedSystemName=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemName'); var SelectedSystemID= $scope.GetAAwindowStoreData(windowviewid,'SelectedSystemID'); angular.forEach(aaPinData, function (value, key) { if(SelectedSystemID=="0") { allPinDataArray.push(value._PinId); $scope.drawStaticPinsOnImage('aaDetailViewCanvas_'+windowviewid, value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY,windowviewid) } else { if (value._BodySystemId == SelectedSystemID) { allPinDataArray.push(value._PinId); $scope.drawStaticPinsOnImage('aaDetailViewCanvas_'+windowviewid, value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY,windowviewid) } } }) var isShowSelectedSystemPinsClicked=$scope.GetAAwindowStoreData(windowviewid,'isShowSelectedSystemPinsClicked'); if (isShowSelectedSystemPinsClicked == false) { $scope.SetAAwindowStoreData(windowviewid,'isShowSelectedSystemPinsClicked',true); //load search/vocab data $rootScope.aaloadSearchData(windowviewid); } else { $scope.EnableUI(); } if (isSliderChange == true) { $scope.activePinOnLayerChange(windowviewid); } // true only for slider change if (islayerChange == true) { $scope.activePinOnSliderChange(windowviewid); } } } $scope.loadAllPinFirstTime=function(windowviewid) { var imageName = $scope.GetAAwindowStoreData(windowviewid,'imageName'); var promise = ModuleService.getPinDataForImage(imageName) .then( function (result) { //load navigator image var navigatorimage= result.data.Root._NavigatorImage; if (navigatorimage != undefined && navigatorimage!="") { $scope.SetAAwindowStoreData(windowviewid,'navigatorImage',navigatorimage); } var aaPinData=result.data.Root.Item; if (aaPinData != null && aaPinData.length > 0) { $scope.SetAAwindowStoreData(windowviewid,'aaPinData',aaPinData); } }, function (error) { $scope.EnableUI(); console.log(' error in showAllPins: ' + error.statusText); }) } $scope.FilterByImage = function (moduleId, query,windowviewid) { $scope.DisableUI(); if(windowviewid==undefined) { windowviewid= $rootScope.MULTI_VIEW_ID; } console.log(query); //$scope.moduleId = moduleId; $scope.filterstring = true; console.log('loadForModuleById is called'); // $rootScope.moduleName = Modules[moduleId].Name; $scope.SetAAwindowStoreData(windowviewid,'moduleName',"ATLAS_ANATOMY"); while ($scope.searchAAListViewData.length) { $scope.searchAAListViewData.pop(); } var filtercount = 0; if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null && query.selectedbodyregion !== "")) { filtercount = filtercount + 1; localStorage.setItem("CurrentBodyRegion", query.selectedbodyregion); } else { localStorage.setItem("CurrentBodyRegion", ''); } if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null && query.selectedbodysystem !== "")) { filtercount = filtercount + 1; localStorage.setItem("CurrentBodySystem", query.selectedbodysystem); } else { localStorage.setItem("CurrentBodySystem", ''); } if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null && query.selectedorientation !== '')) { filtercount = filtercount + 1; localStorage.setItem("CurrentOrientation", query.selectedorientation); } else { localStorage.setItem("CurrentOrientation", ''); } if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null && query.selectedimagetype !== '')) { filtercount = filtercount + 1; localStorage.setItem("CurrentImageType", query.selectedimagetype); } else { localStorage.setItem("CurrentImageType", ''); } var promise = ModuleService.loadModuleDataBasedOnModuleName(Modules[moduleId].Name) .then( function (result) { $scope.moduleLandingData = result; $scope.selectedAAListViewData = new jinqJs() .from($scope.moduleLandingData.data.root.Item) .orderBy([{ field: '_Title', sort: 'asc' }]) .select(); $('#grid-view').empty(); angular.forEach($scope.selectedAAListViewData, 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 (selectimg === true && count >= filtercount) { $scope.imagePath = "../content/images/aa/thumbnails/" + value._TileImageName; var $el = $('
' + '
').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); $scope.searchAAListViewData.push( { "_Id": value._Id, "_ImageId": value._ImageId, "_Title": value._Title, "_ImageName": value._contentImage, "_TileImageName": value._ThumbnailImage, "_BodySystem": value._BodySystem, "_BodyRegion": value._BodyRegion, "_ViewOrientation": value._ViewOrientation, "_ImageType": value._ImageType //"$$hashKey": value._Summary }); if ($('#searchItem').length > 0) $('#searchItem').remove(); } }); //Show Error Message in case of gridview/ ListView [if no data is found] if ($scope.searchAAListViewData.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(); }, 500); }, function (error) { $timeout(function () { $scope.EnableUI(); }, 500); console.log(' error: ' + error.statusText); } ) } $scope.Reset = function (moduleId, query,windowviewid) { if(windowviewid==undefined) // call from also home controller list manager windowviewid= $rootScope.MULTI_VIEW_ID; query.selectedbodyregion = ""; query.selectedbodysystem = ""; query.selectedorientation = ""; query.selectedimagetype = ""; query.selectedspecialty = ""; //set localstorage values localStorage.setItem("CurrentBodyRegion", ''); localStorage.setItem("CurrentBodySystem", ''); localStorage.setItem("CurrentOrientation", ''); localStorage.setItem("CurrentImageType", ''); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $('#ListViewDiv').scrollTop(0); if ($('#demoView').length > 0) $('#demoView').remove(); $scope.filterstring = false; $scope.FilterByImage(1, query,windowviewid); } $scope.showSelectedSystemPins = function (event,windowviewid) { if (typeof event == "object") { var len= (event.target.parentElement.parentElement.id).split("_").length; var windowviewid = (event.target.parentElement.parentElement.id).split("_")[len-1]; if (event.currentTarget.title == $("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title")) { } else { $rootScope.UnsaveCurriculum =true; var id = event.currentTarget.id; $scope.SetAAwindowStoreData(windowviewid,'typeOfEvent',typeof event); var SelectedSystemID = event.currentTarget.id; var SelectedSystemTitle = event.currentTarget.title; if (event.currentTarget.title == "Current Structure") { $scope.SetAAwindowStoreData(windowviewid, 'SelectedSystemID', 0); } else { $scope.SetAAwindowStoreData(windowviewid,'clickedPins',[]); $scope.SetAAwindowStoreData(windowviewid, 'activePinArray', []); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'SelectedSystemID', id); } var isHidePinBtnClicked=$scope.GetAAwindowStoreData(windowviewid,'isHidePinBtnClicked'); $scope.SetAAwindowStoreData(windowviewid,'isBodySystemSelected',true); $scope.SetAAwindowStoreData(windowviewid,'isShowSelectedSystemPinsClicked',true); var bodySystemListObj = document.getElementById("bodySystemList_" + windowviewid ).getElementsByTagName("a"); var bodySystemListlength = bodySystemListObj.length; for (var i = 0; i < bodySystemListlength; i++) { $(bodySystemListObj[i].parentElement).removeClass("activeAASystemSelect"); //add class for selected element if(i==SelectedSystemID) { $(bodySystemListObj[i].parentElement).addClass("activeAASystemSelect"); } } $scope.DisableUI(); $scope.removeSpeechBubble(windowviewid); if (SelectedSystemID == "0") { $scope.SetAAwindowStoreData(windowviewid,'selectedSystemName',null); if (isHidePinBtnClicked) { $scope.showAllPinsAfterHide(windowviewid); } else { //#30499 : Atlas Anatomy > All Pins are not appeared on the body system even after selecting the Body System: All $('#aaDetailViewCanvas_'+windowviewid).removeLayers(); $scope.showAllPins(windowviewid); } } else { var selectedSystemName = SelectedSystemTitle; $scope.SetAAwindowStoreData(windowviewid,'selectedSystemName',selectedSystemName); //on gettng all required data, draw pins var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); if (aaPinData != null && aaPinData.length > 0) { var selectedSystemPinData = new jinqJs() .from(aaPinData) .where("_BodySystemName == " + selectedSystemName) .select(); $scope.SetAAwindowStoreData(windowviewid,'selectedSystemPinData',selectedSystemPinData); if (isHidePinBtnClicked) { $scope.showAllPinsAfterHide(windowviewid); } else { //remove other system pins if (selectedSystemPinData != null && selectedSystemPinData.length > 0) { angular.forEach(aaPinData, function (aaPinDataValue, aaPinDataKey) { if (aaPinDataValue._BodySystemName != selectedSystemName) { $scope.removePin('aaDetailViewCanvas_'+windowviewid, aaPinDataValue._PinId,windowviewid); } }) angular.forEach(selectedSystemPinData, function (value, key) { $scope.drawStaticPinsOnImage('aaDetailViewCanvas_'+windowviewid, value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY,windowviewid) }); // make all pin heads grey var radial = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#aaDetailViewCanvas_'+windowviewid).setLayers({ fillStyle: radial, }).drawLayers(); //show annotation on first pin of the sysyem $scope.showAnnotation(selectedSystemPinData, false, false, false,false,windowviewid); var annotationTopPos = $(".common-drag").css("top").split("p"); $("#canvasAADiv_" + windowviewid).scrollTop(annotationTopPos[0]); } } } } } } else { var SelectedSystemID = event; $scope.SetAAwindowStoreData(windowviewid,'typeOfEvent',typeof event); $scope.SetAAwindowStoreData(windowviewid,'isShowSelectedSystemPinsClicked',true); var bodySystemListObj = document.getElementById("bodySystemList_" + windowviewid ).getElementsByTagName("a"); var bodySystemListlength = bodySystemListObj.length; for (var i = 0; i < bodySystemListlength; i++) { $(bodySystemListObj[i].parentElement).removeClass("activeAASystemSelect"); //add class for selected element if(i==SelectedSystemID) { $(bodySystemListObj[i].parentElement).addClass("activeAASystemSelect"); } } var SelectedSystemTitle = $("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title"); $scope.DisableUI(); var isHidePinBtnClicked=$scope.GetAAwindowStoreData(windowviewid,'isHidePinBtnClicked'); $scope.removeSpeechBubble(windowviewid); if (SelectedSystemID == "0") { $scope.SetAAwindowStoreData(windowviewid,'selectedSystemName',null); if (isHidePinBtnClicked) { $scope.showAllPinsAfterHide(windowviewid); } else { $scope.showAllPins(windowviewid); } } else { var selectedSystemName = SelectedSystemTitle; $scope.SetAAwindowStoreData(windowviewid,'selectedSystemName',selectedSystemName); //on gettng all required data, draw pins var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); if (aaPinData != null && aaPinData.length > 0) { var selectedSystemPinData = new jinqJs() .from(aaPinData) .where("_BodySystemName == " + selectedSystemName) .select(); var oldSelectedSystemId = $scope.GetAAwindowStoreData(windowviewid, 'SelectedSystemID'); if(oldSelectedSystemId!=SelectedSystemID) { $scope.SetAAwindowStoreData(windowviewid,'clickedPins',[]); $scope.SetAAwindowStoreData(windowviewid, 'activePinArray', []); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'SelectedSystemID', SelectedSystemID); } var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); if(clickedPins.length>0) { var pintToshowSelected = new jinqJs() .from(selectedSystemPinData) .where("_PinId == " + clickedPins[0].id) .select(); } else{ var pintToshowSelected=selectedSystemPinData; } $scope.SetAAwindowStoreData(windowviewid,'selectedSystemPinData',selectedSystemPinData); if (isHidePinBtnClicked) { $scope.showAllPinsAfterHide(windowviewid); } else { //remove other system pins if (selectedSystemPinData != null && selectedSystemPinData.length > 0) { angular.forEach(aaPinData, function (aaPinDataValue, aaPinDataKey) { if (aaPinDataValue._BodySystemName != selectedSystemName) $scope.removePin('aaDetailViewCanvas_'+windowviewid, aaPinDataValue._PinId,windowviewid); }) angular.forEach(selectedSystemPinData, function (value, key) { $scope.drawStaticPinsOnImage('aaDetailViewCanvas_'+windowviewid, value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY,windowviewid) }); // make all pin heads grey var radial = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#aaDetailViewCanvas_'+windowviewid).setLayers({ fillStyle: radial, }).drawLayers(); //show annotation on first pin of the sysyem $scope.showAnnotation(pintToshowSelected, false, false, false,true,windowviewid); } } } } } } $scope.showAnnotation = function (selectedPinData, isCtrlPressed, isPinClicked, isItemSearched,isResize,windowviewid) { var isSameTermWithMultiPin = false; var firstPinId = selectedPinData[0]._PinId; var pinTermNumber = selectedPinData[0]._TermId; var isBodySystemSelected= $scope.GetAAwindowStoreData(windowviewid,'isBodySystemSelected'); //check if other pin have same termNumber var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); if (aaPinData != null && aaPinData.length > 0) { var pinDataWithFirstTermNumber = new jinqJs() .from(aaPinData) .where("_TermId == " + pinTermNumber) .select(); var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); for (var i = 0; i <= pinDataWithFirstTermNumber.length - 1; i++) { var pinvalue='PinArc_' + pinDataWithFirstTermNumber[i]._PinId; var isFound = jQuery.inArray(pinvalue, activePinArray) if (isFound == -1) { activePinArray.push('PinArc_' + pinDataWithFirstTermNumber[i]._PinId); } } $scope.MultiLanguageAnnationArray = []; $scope.GetAnnotationBasedOnActualTermNo(pinTermNumber,windowviewid); if (isCtrlPressed) { } else { if (isPinClicked || isItemSearched) { var existingSpeechBubble = $("div[id*='speechBubble']"); for (var i = 0; i < existingSpeechBubble.length; i++) { var len= (existingSpeechBubble[i].id).split("_").length; var winid = (existingSpeechBubble[i].id).split("_")[len-1]; if(winid==windowviewid) { existingSpeechBubble[i].parentNode.removeChild(existingSpeechBubble[i]); //make all pin heads grey var radial = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#aaDetailViewCanvas_'+windowviewid).setLayers({ fillStyle: radial, }).drawLayers(); } } var existingSpeechBubbleLine = $("div[id*='speechBubbleLine']"); for (var i = 0; i < existingSpeechBubbleLine.length; i++) { var len= (existingSpeechBubbleLine[i].id).split("_").length; var winid = (existingSpeechBubbleLine[i].id).split("_")[len-1]; if(winid==windowviewid) { existingSpeechBubbleLine[i].parentNode.removeChild(existingSpeechBubbleLine[i]); } } var speechBubbleDraggedLine = $("div[id*='speechBubbleDraggedLine']"); for (var i = 0; i < speechBubbleDraggedLine.length; i++) { var len= (speechBubbleDraggedLine[i].id).split("_").length; var winid = (speechBubbleDraggedLine[i].id).split("_")[len-1]; if(winid==windowviewid) { speechBubbleDraggedLine[i].parentNode.removeChild(speechBubbleDraggedLine[i]); } } } } if (pinDataWithFirstTermNumber.length > 1) { isSameTermWithMultiPin = true; } var selectedPins=$scope.GetAAwindowStoreData(windowviewid,'selectedPins'); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); angular.forEach(pinDataWithFirstTermNumber, function (value, key) { if (isBodySystemSelected == true) { clickedPins.push({ 'id': value._PinId }); //selectedPins.push(value._PinId); $scope.SetAAwindowStoreData(windowviewid,'isBodySystemSelected',false); } var headX = (parseInt(value._HeadX)); var headY = (parseInt(value._HeadY)); $scope.createSpeechBubble(parseInt(headX) + 10, parseInt(headY) + 10,0,0, value._PinId, isCtrlPressed, isPinClicked, isSameTermWithMultiPin,windowviewid); // remove annotation/speechBubble while resize if(isResize) { $scope.removeSpeechBubble(windowviewid); } //Save Cordinate for show annotation as per Pin if ($rootScope.isCallFromOtherModule) { var CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); CBselectedpinCordinate.push( { "hy": headY, "ly": headY+10, "hx": headX, "lx": headX+30, "pinId": value._PinId }); } }) } $scope.EnableUI(); } $scope.removeSpeechBubble = function (windowviewid) { //clear speech bubbles var speechBubbles = $("div[id*='speechBubble']"); if (speechBubbles != null || speechBubbles != undefined && speechBubbles.length > 0) { for (var j = 0; j < speechBubbles.length; j++) { var len= (speechBubbles[j].id).split("_").length; var winid = (speechBubbles[j].id).split("_")[len-1]; if(winid==windowviewid) { speechBubbles[j].parentNode.removeChild(speechBubbles[j]); } } } var speechBubbleLines = $("div[id*='speechBubbleLine']"); if (speechBubbleLines != null || speechBubbleLines != undefined && speechBubbleLines.length > 0) { for (var j = 0; j < speechBubbleLines.length; j++) { var len= (speechBubbleLines[j].id).split("_").length; var winid = (speechBubbleLines[j].id).split("_")[len-1]; if(winid==windowviewid) { speechBubbleLines[j].parentNode.removeChild(speechBubbleLines[j]); } } } var speechBubbleDraggedLines = $("div[id*='speechBubbleDraggedLine']"); if (speechBubbleDraggedLines != null || speechBubbleDraggedLines != undefined && speechBubbleDraggedLines.length > 0) { for (var j = 0; j < speechBubbleDraggedLines.length; j++) { var len= (speechBubbleDraggedLines[j].id).split("_").length; var winid = (speechBubbleDraggedLines[j].id).split("_")[len-1]; if(winid==windowviewid) { speechBubbleDraggedLines[j].parentNode.removeChild(speechBubbleDraggedLines[j]); } } } }; $scope.showSpeechBubble = function (windowviewid) { //clear speech bubbles var speechBubbles = $("div[id*='speechBubble']"); if (speechBubbles != null || speechBubbles != undefined && speechBubbles.length > 0) { for (var j = 0; j < speechBubbles.length; j++) { var len= (speechBubbles[j].id).split("_").length; var winid = (speechBubbles[j].id).split("_")[len-1]; if(winid==windowviewid) { document.getElementById(speechBubbles[j].id).style.visibility = 'visible'; } } } var speechBubbleLines = $("div[id*='speechBubbleLine']"); if (speechBubbleLines != null || speechBubbleLines != undefined && speechBubbleLines.length > 0) { for (var j = 0; j < speechBubbleLines.length; j++) { var len= (speechBubbleLines[j].id).split("_").length; var winid = (speechBubbleLines[j].id).split("_")[len-1]; if(winid==windowviewid) { document.getElementById(speechBubbleLines[j].id).style.visibility = 'visible'; } } } var speechBubbleDraggedLines = $("div[id*='speechBubbleDraggedLine']"); if (speechBubbleDraggedLines != null || speechBubbleDraggedLines != undefined && speechBubbleDraggedLines.length > 0) { for (var j = 0; j < speechBubbleDraggedLines.length; j++) { var len= (speechBubbleDraggedLines[j].id).split("_").length; var winid = (speechBubbleDraggedLines[j].id).split("_")[len-1]; if(winid==windowviewid) { document.getElementById(speechBubbleDraggedLines[j].id).style.visibility = 'visible'; } } } }; $scope.hideSpeechBubble = function (windowviewid) { //clear speech bubbles var speechBubbles = $("div[id*='speechBubble']"); if (speechBubbles != null || speechBubbles != undefined && speechBubbles.length > 0) { for (var j = 0; j < speechBubbles.length; j++) { var len= (speechBubbles[j].id).split("_").length; var winid = (speechBubbles[j].id).split("_")[len-1]; if(winid==windowviewid) { document.getElementById(speechBubbles[j].id).style.visibility = 'hidden'; } } } var speechBubbleLines = $("div[id*='speechBubbleLine']"); if (speechBubbleLines != null || speechBubbleLines != undefined && speechBubbleLines.length > 0) { for (var j = 0; j < speechBubbleLines.length; j++) { var len= (speechBubbleLines[j].id).split("_").length; var winid = (speechBubbleLines[j].id).split("_")[len-1]; if(winid==windowviewid) { document.getElementById(speechBubbleLines[j].id).style.visibility = 'hidden'; } } } var speechBubbleDraggedLines = $("div[id*='speechBubbleDraggedLine']"); if (speechBubbleDraggedLines != null || speechBubbleDraggedLines != undefined && speechBubbleDraggedLines.length > 0) { for (var j = 0; j < speechBubbleDraggedLines.length; j++) { var len= (speechBubbleDraggedLines[j].id).split("_").length; var winid = (speechBubbleDraggedLines[j].id).split("_")[len-1]; if(winid==windowviewid) { document.getElementById(speechBubbleDraggedLines[j].id).style.visibility = 'hidden'; } } } }; $scope.createSpeechBubble = function (x, y,lx,ly, PinId, isCtrlPressed, isPinClicked, isSameTermWithMultiPin,windowviewid) { $scope.longestAnnotation = $scope.MultiLanguageAnnationArray.reduce(function (firstAnnotation, seconAnnotation) { return firstAnnotation.length > seconAnnotation.length ? firstAnnotation : seconAnnotation; }); $scope.createSpeechBubbleBasedOnAnnotationLength(x, y,lx,ly, PinId,windowviewid); // birendra // $scope.ShowHideAnnotationText(windowviewid); } $scope.createSpeechBubbleBasedOnAnnotationLength = function (x, y, lx, ly, PinId, windowviewid) { var prctValue = $scope.GetAAwindowStoreData(windowviewid,'sliderPercentValue'); x = x * prctValue; y = y * prctValue; if ($("#canvasAADiv_" + windowviewid).find("div").length > 0) { $("#canvasAADiv_" + windowviewid).find("div").each(function () { var str = $(this).attr("id"); if (str.substr(0, 16) == "speechBubbleLine") { str = (str).split("_")[0]; var res = str.substr(16); if (res == PinId) { $scope.isAnnotationDivAlreadyPresent = false; } else { $scope.isAnnotationDivAlreadyPresent = true; } } }); } else { $scope.isAnnotationDivAlreadyPresent = true; } if ($scope.isAnnotationDivAlreadyPresent == true) { var isShowBodyWithCBPinData=$scope.GetAAwindowStoreData(windowviewid,'isShowBodyWithCBPinData'); var speechBubbleHTML = '
' + '
' + '' + '
' + ''; //Issue #7286 :Undefined annotation should not appear var speechbubbleDivId="speechBubble" + PinId +'_'+windowviewid; var speechBubbleLineDivId="speechBubbleLine" + PinId +'_'+windowviewid ; for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) { var MultipleLanguage = $scope.MultiLanguageAnnationArray[i]; } if (MultipleLanguage == undefined) { console.log("No text is found"); } else { $("#canvasAADiv_" + windowviewid).append(speechBubbleHTML); if ($scope.MultiLanguageAnnationArray.length > 0) { for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) { var MultipleLanguage = $scope.MultiLanguageAnnationArray[i]; $("#"+speechbubbleDivId).append("

" + MultipleLanguage + "

"); } } else { console.log('MultiLanguageAnnationArray.length is :' + $scope.MultiLanguageAnnationArray.length) } if ($scope.longestAnnotation != null || $scope.longestAnnotation != undefined) { $("#"+speechbubbleDivId).css("min-width", "auto"); $("#"+speechbubbleDivId).css("white-space", "nowrap"); } } var speechBubbleDims = []; var speechBubbleDimaensions=$scope.GetAAwindowStoreData(windowviewid,'speechBubbleDimaensions'); if(speechBubbleDimaensions.length>0) { var ismatch=false; for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { if (speechBubbleDimaensions[i].speechBuubleId == speechbubbleDivId) { speechBubbleDimaensions[i].speechBubbleLineId =speechBubbleLineDivId; speechBubbleDimaensions[i].currentX =x; speechBubbleDimaensions[i].currentY =y; ismatch=true; } } if(ismatch==false) { speechBubbleDimaensions.push( { "speechBuubleId": speechbubbleDivId, "speechBubbleLineId": speechBubbleLineDivId, "currentX": x, "currentY": y, "pinId": PinId }); } } else { speechBubbleDimaensions.push( { "speechBuubleId": speechbubbleDivId, "speechBubbleLineId": speechBubbleLineDivId, "currentX": x, "currentY": y, "pinId": PinId }); } speechBubbleDims.push({ currentX: x, currentY: y }); document.getElementById(speechBubbleLineDivId).style.display = 'block'; document.getElementById(speechBubbleLineDivId).style.left = ((speechBubbleDims[0].currentX - 12)) + 'px'; var sliderVal=$scope.GetAAwindowStoreData(windowviewid,'sliderVal'); if (sliderVal == 25) { document.getElementById(speechBubbleLineDivId).style.top = ((speechBubbleDims[0].currentY + 5)) + 'px'; } else { document.getElementById(speechBubbleLineDivId).style.top = ((speechBubbleDims[0].currentY)) + 'px'; } document.getElementById(speechbubbleDivId).style.display = 'block'; document.getElementById(speechbubbleDivId).style.left = (speechBubbleDims[0].currentX +20) + 'px'; document.getElementById(speechbubbleDivId).style.top = (speechBubbleDims[0].currentY) + 'px'; if (isShowBodyWithCBPinData == true) { document.getElementById(speechbubbleDivId).style.left = (lx) + 'px'; document.getElementById(speechbubbleDivId).style.top = (ly) + 'px'; var bubble = document.getElementById(speechbubbleDivId); var bulleleft=bubble.offsetLeft; var bulletop=bubble.offsetTop; var sppechBubbleId = PinId +'_'+windowviewid; var speechBubbleDraggedLineID = "speechBubbleDraggedLine" + sppechBubbleId; $("#speechBubbleLine" + sppechBubbleId).css("visibility", "hidden"); $("#speechBubbleLine" + sppechBubbleId).css("display", "none"); for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { if (speechBubbleDimaensions[i].speechBuubleId == speechbubbleDivId) { speechBubbleDimaensions[i].speechBubbleLineId =speechBubbleDraggedLineID; $scope.angle(speechBubbleDraggedLineID, speechBubbleDimaensions[i].currentX, speechBubbleDimaensions[i].currentY, bulleleft + 20, bulletop + 20, true,windowviewid); } } } } $('.common-drag').draggable( { containment: '#canvasAADiv_' + windowviewid, drag: function (evt) { //stop: function (evt) { var clickedSpeechBubbleId = $(this).attr("id"); var len= (clickedSpeechBubbleId).split("_").length; var windowviewid = (clickedSpeechBubbleId).split("_")[len-1]; var verticalScrollPosition = document.getElementById('canvasAADiv_'+windowviewid).scrollTop; var horizontlScrollPosition = document.getElementById('canvasAADiv_' + windowviewid).scrollLeft; //Calling Method to save ScrollPosition for Save CB $scope.SetAAwindowStoreData(windowviewid, 'verticalScroll', verticalScrollPosition); $scope.SetAAwindowStoreData(windowviewid, 'horizontalScroll', horizontlScrollPosition); var sppechBubbleId = $(this).attr("id").substring(12); var speechBubbleDraggedLineID = "speechBubbleDraggedLine" + sppechBubbleId; $("#speechBubbleLine" + sppechBubbleId).css("visibility", "hidden"); $("#speechBubbleLine" + sppechBubbleId).css("display", "none"); var speechBubbleDimaensions=$scope.GetAAwindowStoreData(windowviewid,'speechBubbleDimaensions'); for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { if (speechBubbleDimaensions[i].speechBuubleId == clickedSpeechBubbleId) { speechBubbleDimaensions[i].speechBubbleLineId =speechBubbleDraggedLineID; $scope.angle(speechBubbleDraggedLineID, speechBubbleDimaensions[i].currentX, speechBubbleDimaensions[i].currentY, evt.pageX + horizontlScrollPosition - $('#canvasAADiv_' + windowviewid).offset().left, evt.pageY + verticalScrollPosition - $('#canvasAADiv_' + windowviewid).offset().top, true, windowviewid); } } }, stop: function (evt) { var clickedSpeechBubbleId = $(this).attr("id"); var len = (clickedSpeechBubbleId).split("_").length; var windowviewid = (clickedSpeechBubbleId).split("_")[len - 1]; var sppechBubbleId = $(this).attr("id").substring(12); var PinId = sppechBubbleId.split("_")[0]; if ($rootScope.isCallFromOtherModule) { $rootScope.UnsaveCurriculum = true; $timeout(function () { var CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); var BubleObj = document.getElementById(clickedSpeechBubbleId); var CBselectedpinCordinate = new jinqJs() .from(CBselectedpinCordinate) .update(function (coll, index) { coll[index].lx = BubleObj.offsetLeft; coll[index].ly = BubleObj.offsetTop; }) .at("pinId == " + PinId); }, 100); } } }); $('.crossDiv_temp').on('click', function (evt) { var imgId = $(this).attr("id"); var len= (imgId).split("_").length; var windowviewid = (imgId).split("_")[len-1]; var imgDivId=(imgId).split("_")[0]; var pinId = imgDivId.substring(8, imgDivId.length); $('#speechBubble' + pinId+'_'+windowviewid).remove(); $("#speechBubbleDraggedLine" + pinId+'_'+windowviewid).remove(); $("#speechBubbleLine" + pinId + '_' + windowviewid).remove(); if ($rootScope.isCallFromOtherModule) { var CBselectedpinCordinate = []; CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); CBselectedpinCordinate = new jinqJs() .from(CBselectedpinCordinate) .delete().at("pinId == " + pinId).select(); $scope.SetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate', CBselectedpinCordinate); $rootScope.UnsaveCurriculum = true; } }); //make the head green var radialAfterClick = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(126, 187, 83)' }); var pinHeadName = 'PinArc_' + PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinHeadName, { fillStyle: radialAfterClick, }).drawLayers(); var typeOfEvent=$scope.GetAAwindowStoreData(windowviewid,'typeOfEvent'); if (typeOfEvent == "string") { var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); for (var i = 0; i <= clickedPins.length - 1; i++) { var pinHeadName = 'PinArc_' + clickedPins[i].id; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinHeadName, { fillStyle: radialAfterClick, }).drawLayers(); } } } $scope.angle = function (dragLineId, cx, cy, ex, ey, BoolValues,windowviewid) { var dy = ey - cy; var dx = ex - cx; var theta = 0; if (dx < 0) { theta = Math.atan(dy / dx) * (180 / Math.PI); theta = theta + 180; } else if (dy < 0) { theta = Math.atan(dy / dx) * (180 / Math.PI); theta = theta + 360; } else { theta = Math.atan(dy / dx) * (180 / Math.PI); } var d = Math.sqrt((cx - ex) * (cx - ex) + (cy - ey) * (cy - ey)); var e = cy; var f = cx; if (BoolValues == true) { var sliderVal=$scope.GetAAwindowStoreData(windowviewid,'sliderVal'); if (sliderVal == 40) { $("#" + dragLineId).css({ 'display': 'block', 'width': d + 'px', 'top': (e - 5) + 'px', 'left': (f - 5) + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } else if (sliderVal == 25) { $("#" + dragLineId).css({ 'display': 'block', 'width': d + 'px', 'top': (e - 2) + 'px', 'left': (f - 2) + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } else { $("#" + dragLineId).css({ 'display': 'block', 'width': d + 'px', 'top': (e - 10) + 'px', 'left': (f - 5) + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } } else { $("#bord_annotation").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } } $scope.drawStaticPinsOnImage = function (canvasId, PinId, offsetX1, offsetY1, x, y,windowviewid) { var slidpercentValue= $scope.GetAAwindowStoreData(windowviewid,'sliderPercentValue'); var multipliedByValue = 5; var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { multipliedByValue = 10; } console.log('isSliderrChange') var radial = $('#' + canvasId).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#' + canvasId).drawLine({ layer: true, name: "Pin_" + PinId, groups: ["Pin_" + PinId], strokeStyle: '#565656', strokeWidth: 2, visible: true, x1: offsetX1 * slidpercentValue, y1: offsetY1 * slidpercentValue, x2: x * slidpercentValue, y2: y * slidpercentValue, }).drawArc({ name: "PinArc_" + PinId, layer: true, groups: ["Pin_" + PinId], strokeStyle: 'grey', strokeWidth: 2, visible: true, fillStyle: radial, x: x * slidpercentValue, y: y * slidpercentValue, radius: 10, click: function (clickedPin) { $rootScope.UnsaveCurriculum =true; //birendra // for mac os Command key use for multi selection if (clickedPin.event.ctrlKey == false && clickedPin.event.metaKey == false) { $scope.SetAAwindowStoreData(windowviewid, 'clickedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate', []); } var pinID = (clickedPin.name).substring(7, (clickedPin.name).length); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var pinData = new jinqJs() .from(aaPinData) .where("_PinId == " + pinID) .select(); var pinTermNumber = pinData[0]._TermId; var pinWithSameTerm = new jinqJs() .from(aaPinData) .where("_TermId == " + pinTermNumber) .select(); if (pinWithSameTerm != undefined && pinWithSameTerm != null && pinWithSameTerm.length > 0) { var selectedPins = $scope.GetAAwindowStoreData(windowviewid, 'selectedPins'); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); for (var i = 0; i < pinWithSameTerm.length; i++) { clickedPins.push({ 'id': pinWithSameTerm[i]._PinId }); selectedPins.push(pinWithSameTerm[i]._PinId); } } $scope.SetAAwindowStoreData(windowviewid,'isSelectedPinBtnClickedAftrSliderCange',false); var selectedPinData = new jinqJs() .from(aaPinData) .where("_PinId == " + pinID) .select(); var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); if (clickedPin.event.ctrlKey == true||clickedPin.event.metaKey == true) { var isFound = jQuery.inArray(clickedPin.name, activePinArray) if (isFound == -1) { activePinArray.push(clickedPin.name); } var radialAfterClick = $('#aaDetailViewCanvas_' + windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(126, 187, 83)' }); clickedPin.fillStyle = radialAfterClick; $scope.showAnnotation(selectedPinData, true, true, false,false, windowviewid); } else { $scope.SetAAwindowStoreData(windowviewid,'activePinArray',[]); var activePin = []; activePin.push(clickedPin.name); $scope.SetAAwindowStoreData(windowviewid,'activePinArray',activePin); var radial = $('#aaDetailViewCanvas_' + windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#aaDetailViewCanvas_' + windowviewid).setLayers({ fillStyle: radial, }).drawLayers(); //change the head color to green var radialAfterClick = $('#aaDetailViewCanvas_' + windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(126, 187, 83)' }); clickedPin.fillStyle = radialAfterClick; $scope.showAnnotation(selectedPinData, false, true, false,false, windowviewid); } } }).drawLayers(); } $scope.getMousePos = function (evt) { return { x: Math.round(evt.pageX - $('#canvasDiv').offset().left), y: Math.round(evt.pageY - $('#canvasDiv').offset().top) } } $scope.removePin = function (canvasId, pinId,windowviewid) { var pinName = 'Pin_' + pinId; var pinArcName = 'PinArc_' + pinId; $('#' + canvasId).removeLayer(pinName).drawLayers(); $('#' + canvasId).removeLayer(pinArcName).drawLayers(); $scope.removeSpeechBubble(windowviewid); } $rootScope.aaAnnotationToolEvent = 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" }); $('#canvasAA_'+windowviewid).css("display", "block"); $('#canvasPaintAA_'+windowviewid).css("display", "block"); } $rootScope.aaloadSearchData = function (windowviewid) { var imageId= $scope.GetAAwindowStoreData(windowviewid,'imageId'); var promise = ModuleService.getTermTextDataForAAImage(imageId) .then( function (response) { var AAPinTermData = response.data.PinTermData.TermData; $scope.SetAAwindowStoreData(windowviewid,'AAPinTermData',AAPinTermData) $scope.EnableUI(); $scope.SetAAwindowStoreData(windowviewid,'pinTermData',[]); var primaryLexicon = $rootScope.lexiconLanguageArray[0].id; var matchedLanguageTermData = new jinqJs() .from(AAPinTermData) .where('_LanguageId == ' + primaryLexicon) .select(); var sortedTermTextArray = []; for (var i = 0; i < matchedLanguageTermData.length; i++) { sortedTermTextArray.push(matchedLanguageTermData[i]._TermText); sortedTermTextArray.sort(); } var pinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData'); for (var i = 0; i <= sortedTermTextArray.length - 1; i++) { for (var j = 0; j <= matchedLanguageTermData.length - 1; j++) { if (matchedLanguageTermData[j]._TermText == sortedTermTextArray[i]) { pinTermData.push({ "LanguageId": matchedLanguageTermData[j]._LanguageId, "TermNumber": matchedLanguageTermData[j]._TermNumber, "TermTxt": matchedLanguageTermData[j]._TermText }); break; } } } $("#AABodySystems").empty(); $("#bodySystems").css("display", "none"); $("#AABodySystems").css("display", "block"); $("#bodySystemList_" + windowviewid + " li a").each(function (key, value) { var sysid= $(this).attr('id') + '_' +windowviewid; if ($(this).parent().hasClass("disabledSelectedSystem")) { var $systemOptions = $('').appendTo("#AABodySystems") $compile($systemOptions)($scope); } else{ var $systemOptions = $('').appendTo("#AABodySystems") $compile($systemOptions)($scope); } }); $scope.$watch('pinTermData', function (newValue, oldValue, scope) { $('#termlistfilter_' + windowviewid).empty(); if (pinTermData.length > 0) { $timeout(function () { console.log('pinTermData= ' + pinTermData.length); $('#termList').empty(); $('#termlistfilter_' + windowviewid).empty(); for (var j = 0; j < pinTermData.length; j++) { var $el = $('
  • ' + pinTermData[j].TermTxt + '
  • ').appendTo('#termlistfilter_' + windowviewid) $compile($el)($scope); var $selectedOptions = $('').appendTo('#termList') $compile($selectedOptions)($scope); } }, 500); } }) }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } //event remove it fire multiple time $rootScope.aalistManagerEvent=function(windowviewid){ $scope.DisableUI(); $rootScope.aaloadSearchData(windowviewid); $timeout(function () { $("#totalTerms").empty(); $("#totalTerms").html("" + $("#termList option").length + " Structures"); $scope.EnableUI(); }, 1000); } $rootScope.refreshTermListOnAASystemSelection = function (selectedBodysystemId) { var windowviewid = (selectedBodysystemId).split("_")[1]; $("#AABodySystems").find("option:not(:disabled)").css({ "background-color": "#ffffff", "color": "#000000" }); $("#AABodySystems").find("option[id=" + selectedBodysystemId + "]").css({ "background-color": "#3399FF", "color": "#ffffff" }); $('#termList').empty(); var bodySystemName = $("#AABodySystems #" + selectedBodysystemId).val(); if (bodySystemName == "All") { var pinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData'); for (var j = 0; j <= pinTermData.length - 1; j++) { var $selectedOptions = $('').appendTo("#termList") $compile($selectedOptions)($scope); } $("#totalTerms").empty(); $("#totalTerms").html("" + $("#termList option").length + " Structures"); } else { var imageId = $scope.GetAAwindowStoreData(windowviewid,'imageId'); var pinDataUrl = "aa_dat_pinterm_" + imageId; var bodySystemTermArray = []; var sortedListArray = []; var duplicateListArray = []; $.ajax({ url: '~/../content/data/json/aa/aa_pinterm/' + pinDataUrl + '.json', type: 'GET', dataType: "json", async: false, success: function (result) { $(result.PinTermData.TermData).each(function (key, value) { bodySystemTermArray.push({ "termNumbr": result.PinTermData.TermData[key]._TermNumber, "text": result.PinTermData.TermData[key]._TermText, "language": result.PinTermData.TermData[key]._LanguageId }); }); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); for (var i = 0; i <= aaPinData.length - 1; i++) { if (aaPinData[i]._BodySystemName.toLowerCase() == bodySystemName.toLowerCase()) { for (var j = 0 ; j <= bodySystemTermArray.length - 1; j++) { if (aaPinData[i]._TermId == bodySystemTermArray[j].termNumbr) { if (bodySystemTermArray[j].language == $rootScope.lexiconLanguageArray[0].id) { duplicateListArray.push({ "title": bodySystemTermArray[j].text, "id": bodySystemTermArray[j].termNumbr }); } } } } } var temp = []; for (var i = 0; i <= duplicateListArray.length - 1; i++) { var termID = duplicateListArray[i].id; if ($.inArray(termID, temp) == -1) { temp.push(termID); sortedListArray.push({ "title": duplicateListArray[i].title, "id": termID }); } } for (var i = 0; i <= sortedListArray.length - 1; i++) { for (j = i + 1; j <= sortedListArray.length - 1; j++) { if (sortedListArray[i].title.substr(0, 1) > sortedListArray[j].title.substr(0, 1)) { var termText = sortedListArray[i].title; var termNumbr = sortedListArray[i].id; var termLanguage = sortedListArray[i].language; sortedListArray[i].title = sortedListArray[j].title; sortedListArray[i].id = sortedListArray[j].id; sortedListArray[i].language = sortedListArray[j].language; sortedListArray[j].title = termText; sortedListArray[j].id = termNumbr; sortedListArray[j].language = termLanguage; } } } for (var j = 0; j <= sortedListArray.length - 1; j++) { var $selectedOptions = $('').appendTo("#termList"); $compile($selectedOptions)($scope); } } }); $("#totalTerms").empty(); $("#totalTerms").html("" + $("#termList option").length + " Structures"); } } $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo,windowviewid) { var languageArray = $rootScope.lexiconLanguageArray; var AAPinTermData= $scope.GetAAwindowStoreData(windowviewid,'AAPinTermData'); if (AAPinTermData != null || AAPinTermData != undefined) { var matchedTermNoData = new jinqJs() .from(AAPinTermData) .where('_TermNumber == ' + actualTermNo) .select(); if (matchedTermNoData != null || matchedTermNoData != undefined) { for (var j = 0; j <= languageArray.length - 1; j++) { $scope.matchedLanguageTermNoData = new jinqJs() .from(matchedTermNoData) .where('_LanguageId == ' + languageArray[j].id) .select(); var termText = $scope.matchedLanguageTermNoData[0]._TermText; $scope.MultiLanguageAnnationArray.push(termText); }; } } } $rootScope.hidePinsevent = function (windowviewid) { $rootScope.UnsaveCurriculum = true; $rootScope.hidePins(windowviewid); } $rootScope.hidePins = function (windowviewid) { $scope.ToolBoxStyle("HidePin",windowviewid); $scope.DisableUI(); $scope.hideSpeechBubble(windowviewid); $scope.SetAAwindowStoreData(windowviewid, 'isShowSelectedPins', false); $scope.SetAAwindowStoreData(windowviewid, 'isShowAllPins', false); $scope.SetAAwindowStoreData(windowviewid, 'isHidePinBtnClicked', true); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); angular.forEach(aaPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue._PinId; var pinArcName = 'PinArc_' + aaPinDataValue._PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: false // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: false // set to true instead to show the layer again }).drawLayers(); }) $scope.EnableUI(); } $scope.showAllPinEvent = function (windowviewid) { $rootScope.UnsaveCurriculum = true; $scope.showAllPinsAfterHide(windowviewid); } $scope.showAllPinsAfterHide = function (windowviewid) { $scope.ToolBoxStyle("ShowAllPin",windowviewid); $scope.DisableUI(); $scope.SetAAwindowStoreData(windowviewid, 'isShowAllPins', true); $scope.SetAAwindowStoreData(windowviewid,'isHidePinBtnClicked',false); $scope.SetAAwindowStoreData(windowviewid, 'isShowSelectedPins', false); var selectedSystemName=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemName'); if (selectedSystemName != null && selectedSystemName != undefined) { var selectedSystemPinData=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemPinData'); $scope.showSystemPins(selectedSystemPinData, false,windowviewid); } else { var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); $scope.showSystemPins(aaPinData, false,windowviewid); } $scope.showSpeechBubble(windowviewid); var isSliderChange = $scope.GetAAwindowStoreData(windowviewid, 'isSliderChange'); if ($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title") == "Current Structure" || $("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title") == undefined) { if (isSliderChange == true) { $scope.showAllPins(windowviewid); } } else if (isSliderChange) { $scope.showAllPins(windowviewid); } }; $scope.showSelectedPinEvent = function (windowviewid) { $rootScope.UnsaveCurriculum = true; $scope.showSelectedPins(windowviewid); } $scope.showSelectedPins = function (windowviewid) { $scope.ToolBoxStyle("ShowSelectedPin",windowviewid); $("#listManager").css("display", "none"); $("#optionsListManagerTab").removeClass("active"); $scope.DisableUI(); //if ($rootScope.isCallFromOtherModule) { var isHidePinBtnClicked = $scope.GetAAwindowStoreData(windowviewid, 'isHidePinBtnClicked'); if (isHidePinBtnClicked) { $scope.showAllPins(windowviewid); setTimeout(function () { $scope.activePinOnSliderChange(windowviewid); }, 200); } //} $scope.SetAAwindowStoreData(windowviewid, 'isShowAllPins', false); $scope.SetAAwindowStoreData(windowviewid, 'isHidePinBtnClicked', false); $scope.SetAAwindowStoreData(windowviewid, 'isShowSelectedPins', true); var selectedSystemName=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemName'); if (selectedSystemName != null && selectedSystemName != undefined) { var selectedSystemPinData=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemPinData'); $scope.showSystemPins(selectedSystemPinData, true,windowviewid); } else { var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); $scope.showSystemPins(aaPinData, true,windowviewid); } $scope.showSpeechBubble(windowviewid); var isSelectedPinBtnClickedAftrSliderCange= $scope.GetAAwindowStoreData(windowviewid,'isSelectedPinBtnClickedAftrSliderCange'); if (isSelectedPinBtnClickedAftrSliderCange == true) { var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); for (var i = 0; i <= activePinArray.length - 1; i++) { var pinName = activePinArray[i].split("_"); var activePinName = 'Pin_' + pinName[1]; var pinArcName = 'PinArc_' + pinName[1]; $('#aaDetailViewCanvas_'+windowviewid).setLayer(activePinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); } } }; $scope.showSystemPins = function (seletedSystemPinData, isShowSelectedPins, windowviewid) { if (isShowSelectedPins) { var selectedPins = []; $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); angular.forEach(clickedPins, function (value, key) { seletedSystemPinData = new jinqJs() .from(seletedSystemPinData) .where('_PinId != ' + value.id) .select(); selectedPins.push(value.id); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', selectedPins); }); angular.forEach(clickedPins, function (value1, key1) { // if (aaPinDataValue._PinId != value.id) { var pinName = 'Pin_' + value1.id; var pinArcName = 'PinArc_' + value1.id; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); // } }) angular.forEach(seletedSystemPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue._PinId; var pinArcName = 'PinArc_' + aaPinDataValue._PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: false // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: false // set to true instead to show the layer again }).drawLayers(); }) } else { angular.forEach(seletedSystemPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue._PinId; var pinArcName = 'PinArc_' + aaPinDataValue._PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); }) } $scope.EnableUI(); } $scope.showItemsForSearch = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; console.log('showItemsForSearch is called'); //this check is for log only because we are writing length so need to check if its not null or undefined var AAPinTermData=$scope.GetAAwindowStoreData(windowviewid,'AAPinTermData'); $timeout(function () { if ((AAPinTermData != null || AAPinTermData != undefined) && (AAPinTermData.length > 0)) { $scope.IsSearchVisible = true; $("#termlistfilter_" + windowviewid).css("display", "block"); $("#backdrop > #searchListDivAA > #termlistfilter_" + windowviewid + " > li").each(function (key, value) { if ($(this).find("a").html() == document.getElementById("selectedTermName_"+windowviewid).value) { $("#termlistfilter_" + windowviewid + " li a").css({ "background-color": "#ffffff", "color": "#000000" }); $(this).find("a").css({ "background-color": "#3399FF", "color": "#ffffff" }); } }); } else { $rootScope.aaloadSearchData(windowviewid); if (AAPinTermData.length > 0) { $scope.showItemsForSearch(event); } } }, 500); } $scope.HideSearchList = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $timeout(function () { $("#termlistfilter_"+windowviewid).css("display", "none"); }, 500); } $scope.highlightPinBasedOnSerachItemEvent = function (termid) { $rootScope.UnsaveCurriculum = true; $scope.highlightPinBasedOnSerachItem(termid); } $scope.highlightPinBasedOnSerachItem = function (termid) { var windowviewid = (termid).split("_")[1]; var id=(termid).split("_")[0]; var currenttermidTxt = $('#' + termid).text(); $scope.showAllPinsAfterHide(windowviewid); $('#termList option[selected="selected"]').prop("selected", false); $('#termList option[value="' + currenttermidTxt + '"]').attr("selected", true); $("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); $('#termList option[value="' + currenttermidTxt + '"]').css({ "background-color": "#3399FF", "color": "#ffffff" }); $("#termlistfilter_" + windowviewid + " li").find("a").css({ "background-color": "#ffffff", "color": "#000000" }); $("#termlistfilter_" + windowviewid + " li").find("a[id=" + termid + "]").css({ "background-color": "#3399FF", "color": "#ffffff" }); $('#selectedTermName_' + windowviewid).val(currenttermidTxt); //get data from pindata for this trem var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var pinDataForTerm = new jinqJs() .from(aaPinData) .where("_TermId == " + id) .select(); // if ($("#bodySystemList_" + windowviewid +" li.activeAASystemSelect a").attr("id") == 0) { // } // else // { // // birendra // //change body system by searched term // $scope.showSelectedSystemPins(pinDataForTerm[0]._BodySystemId,windowviewid); // } // birendra //change body system by searched term $scope.showSelectedSystemPins(pinDataForTerm[0]._BodySystemId,windowviewid); $timeout(function () { //make all pin heads grey var radial = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#aaDetailViewCanvas_'+windowviewid).setLayers({ fillStyle: radial, }).drawLayers(); console.log(pinDataForTerm[0]._PinId); var pinID = "PinArc_" + pinDataForTerm[0]._PinId; $scope.SetAAwindowStoreData(windowviewid,'clickedPins',[]); var clickpin = []; clickpin.push({ 'id': pinDataForTerm[0]._PinId }); $scope.SetAAwindowStoreData(windowviewid, 'clickedPins', clickpin); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); var selectedPins = []; selectedPins.push(pinDataForTerm[0]._PinId); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', selectedPins); $scope.SetAAwindowStoreData(windowviewid,'activePinArray',[]); var activePin = []; activePin.push(pinID); $scope.SetAAwindowStoreData(windowviewid,'activePinArray',activePin); $scope.showAnnotation(pinDataForTerm, false, false, true,false,windowviewid); // maintaing scroll position on selection of options in list manager. var annotationTopPos = $(".common-drag").css("top").split("p"); $("#canvasAADiv_" + windowviewid).scrollTop(annotationTopPos[0]); },500); $scope.IsSearchVisible = false; } $scope.ShowHideAnnotation = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $rootScope.UnsaveCurriculum = true; var btnStrutureBoxname = document.getElementById("comment-box_"+windowviewid).name; if (btnStrutureBoxname == "showAnnotationText") { $("#comment-box_"+windowviewid).addClass("disableAnnotationText"); document.getElementById("comment-box_"+windowviewid).name = "hideAnnotationText"; $scope.SetAAwindowStoreData(windowviewid, 'showHideAnnotations', 'hideAnnotationText'); } else { $("#comment-box_"+windowviewid).removeClass("disableAnnotationText"); document.getElementById("comment-box_"+windowviewid).name = "showAnnotationText"; $scope.SetAAwindowStoreData(windowviewid, 'showHideAnnotations', 'showAnnotationText'); } $scope.ShowHideAnnotationText(windowviewid); } $scope.ShowHideAnnotationText = function(windowviewid) { var showHideAnnotations = $scope.GetAAwindowStoreData(windowviewid, 'showHideAnnotations'); document.getElementById("comment-box_"+windowviewid).name = showHideAnnotations; var speechBubbleDimaensions=$scope.GetAAwindowStoreData(windowviewid,'speechBubbleDimaensions'); if (showHideAnnotations == "showAnnotationText") { for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { $("#" + speechBubbleDimaensions[i].speechBuubleId).css("display", "block"); $("#" + speechBubbleDimaensions[i].speechBubbleLineId).css("display", "block"); } } else { $("#comment-box_"+windowviewid).addClass("disableAnnotationText"); for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { $("#" + speechBubbleDimaensions[i].speechBuubleId).css("display", "none"); $("#" + speechBubbleDimaensions[i].speechBubbleLineId).css("display", "none"); } } } $scope.activePinOnLayerChange = function (windowviewid) { var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); for (var i = 0; i <= activePinArray.length - 1; i++) { var radialAfterClick = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(126, 187, 83)' }); var clickedPin = activePinArray[i]; $('#aaDetailViewCanvas_'+windowviewid).setLayer(clickedPin, { fillStyle: radialAfterClick }).drawLayers(); } } angular.element(document).click(function (event) { $(".tool-dropdown-menu").css("display", "none"); var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { $(".custom-tooltip").css("display", "none"); } }); $scope.activePinOnSliderChange = function (windowviewid) { var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); var allPinDataArray=$scope.GetAAwindowStoreData(windowviewid,'allPinDataArray'); if (activePinArray.length == 1) { for (var i = 0; i <= allPinDataArray.length - 1; i++) { var activeArc = activePinArray[0].split("_"); if (allPinDataArray[i] == activeArc[1]) { var pinName = 'Pin_' + allPinDataArray[i]; var pinArcName = 'PinArc_' + allPinDataArray[i]; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); } else { var pinName = 'Pin_' + allPinDataArray[i]; var pinArcName = 'PinArc_' + allPinDataArray[i]; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: false // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: false // set to true instead to show the layer again }).drawLayers(); } } } else { var seletedSystemPinData; angular.forEach(activePinArray, function (value, key) { var pinID = value.split("_"); seletedSystemPinData = new jinqJs() .from(allPinDataArray) .where('_PinId != ' + pinID[1]) .select(); }) angular.forEach(seletedSystemPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue; var pinArcName = 'PinArc_' + aaPinDataValue; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: false // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: false // set to true instead to show the layer again }).drawLayers(); }) for (var i = 0; i <= activePinArray.length - 1; i++) { var pinName = activePinArray[i].split("_"); var activePinName = 'Pin_' + pinName[1]; var pinArcName = 'PinArc_' + pinName[1]; $('#aaDetailViewCanvas_'+windowviewid).setLayer(activePinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); } } } $(document).ready(function () { var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { var jspanelContainerWidth = $(".jsPanel-content").css("width"); $(".jsPanel-content").css({ "width": "100%", "min-width": jspanelContainerWidth }); $("#ImagePanel").css("width", "100%"); //hide pin button clicked // $("#hidePinBtn").removeAttr("onclick"); // $("#hidePinBtn").on("touchstart", function () { // var rootScope = angular.element(document.getElementById("aaBodyView")).scope(); // rootScope.$apply(function () { // rootScope.hidePins(event); // }); // }); //selected pin button clicked // $("#selectedPin").removeAttr("onclick"); // $("#selectedPin").on("touchstart", function () { // console.log('showSelectedPins is called') // var scope = angular.element(document.getElementById("aaBodyView")).scope(); // scope.$apply(function () { // scope.showSelectedPins(event); // }); // }); // //all pin button clicked // $("#allPinBtn").removeAttr("onclick"); // $("#allPinBtn").on("touchstart", function () { // var scope = angular.element(document.getElementById("aaDetailPageDiv")).scope(); // scope.$apply(function () { // scope.showAllPinsAfterHide(event); // }); // }); // //comment-box button clicked // $("#comment-box").removeAttr("onclick"); // $("#comment-box").on("touchstart", function () { // var scope = angular.element(document.getElementById("aaDetailPageDiv")).scope(); // scope.$apply(function () { // scope.ShowHideAnnotation(event); // }); // }); } }); //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); $scope.setActiveTab(parseInt($rootScope.getLocalStorageValue("activeTab"))); $(".tools").css("z-index", "15000"); }); } $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.AAWindowData.length; index++) { if ($rootScope.AAWindowData[index].multiwinid == windowviewid) { if (index != -1) { // remove module which one is loaded $rootScope.AAWindowData.splice(index, 1); if ($('#' + panelid).html() != undefined) { $('#' + panelid).remove(); } // $rootScope.resetjsPanelTop(panelid); } } } } }]); function refreshTermListOnSystemSel(bodySystemId) { var rootScope = angular.element(document.getElementById("aaDetailPageDiv")).scope(); rootScope.$apply(function () { rootScope.refreshTermListOnAASystemSelection(bodySystemId); }); } function showSelectedSystemPins(event) { console.log('OnBodySystem chnaged is called outside '); var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { //select system and its related pins scope.showSelectedSystemPins(event); }); } function hidePins(event) { var len= (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len-1]; var rootScope = angular.element(document.getElementById("aaBodyView")).scope(); rootScope.$apply(function () { rootScope.hidePinsevent(windowviewid); //Calling for Save CB Window data //rootScope.updateWindowsContentForSaveCB(); }); } function showAllPins(event) { var len= (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len-1]; var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.showAllPinEvent(windowviewid); }); } function onSearchAA(event) { console.log('AA search is called') var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.showItemsForSearch(event); }); } function hideSearchList(event) { console.log('AA hide search is called') var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.HideSearchList(event); }); } function onSearchItemSelection(termid) { console.log('AA hide search is called'); var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.highlightPinBasedOnSerachItemEvent(termid); }); } function showHideAnnotation(event) { var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.ShowHideAnnotation(event); }); } function showSelectedPins(event) { console.log('showSelectedPins is called') var scope = angular.element(document.getElementById("aaBodyView")).scope(); var len= (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len-1]; scope.$apply(function () { scope.showSelectedPinEvent(windowviewid); }); } function openModuleItemView(event) { var scope = angular.element(document.getElementById("list-view")).scope(); scope.isListViewButtonClicked = true; scope.$apply(function () { scope.openModuleItemView(event); }); } function openListViewModuleItem(event) { var scope = angular.element(document.getElementById("list-view")).scope(); scope.isListViewButtonClicked = true; scope.$apply(function () { scope.openListViewModuleItem(event); }); } function openCurrentView(event) { var scope = angular.element(document.getElementById("list-view")).scope(); scope.isListViewButtonClicked = true; scope.isOpenBtnClicked = true; scope.$apply(function () { scope.openModuleItemView(event); }); } function systemChange(event) { event.stopPropagation(); var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $("#bodySystemList_" + windowviewid ).toggle(); var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { $(".custom-tooltip").toggle(); } } //sidebar toggle function SideBarToggleAA(event) { var len = (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len - 1]; $("#" + event.currentTarget.id).parent().toggleClass('active'); $("#selectedTermName_"+windowviewid).parent().parent().parent().parent().parent().toggleClass('active'); }