'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; 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.initializeAAWindowData = function(windowviewid,isOpenWithExistsModule,cbwindowid){ if(isOpenWithExistsModule ||cbwindowid==0) { if ($rootScope.AAWindowData != undefined) { $rootScope.AAWindowData.length = 0; } else { $rootScope.AAWindowData = []; } $rootScope.AAWindowData.push( { '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, 'top': 0, 'left': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': false, 'id': 0, 'selectedPins': [] }); } 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( { '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, 'top': 0, 'left': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': false, 'id': 0, 'selectedPins': [] }); } } } $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; } } } $rootScope.GetAAWindowId=function() { // handle for single window if($rootScope.AAWindowData.length>0) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ return $rootScope.AAWindowData[x].multiwinid; } } else return 0; } $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 $('#CBDetailPageDiv').css('pointer-events', 'none'); $('#CBDetailPageDiv').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 $('#CBDetailPageDiv').css('pointer-events', 'auto'); $('#CBDetailPageDiv').css('opacity', '1'); } $scope.loadForModuleById = function (moduleId) { // clear data set by curriculum builder $rootScope.isCallFromOtherModule = undefined; $rootScope.MULTI_VIEW_ID += 1 // $scope.ScopeVariablesDeclare(); $scope.initializeAAWindowData($rootScope.MULTI_VIEW_ID,true,undefined); $scope.DisableUI(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $rootScope.openModules.push({ "ModuleId": 2 }); if ($rootScope.refreshcheck == null) { $location.path('/'); } $scope.activeTab = 1; 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(); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); }, 200); $('#list-view').css('display', 'none'); } $scope.openModuleItemView = function (event) { var windowviewid= $rootScope.MULTI_VIEW_ID; $rootScope.MenuModuleName = "AA"; localStorage.setItem("activeTab", $scope.activeTab); //0. Get selected Image Id if ($scope.isListViewButtonClicked == true) { if ($scope.isOpenBtnClicked == true) { var moduleItemDataToBeSaved = $("#demoText").text().trim(); $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 moduleItemDataToBeSaved = event.target.id; localStorage.setItem("listViewSelectedID", event.currentTarget.id); $scope.isListViewButtonClicked = false; } //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
"); } $scope.openModuleItemMain = function () { 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; var slideId = ""; timeint = $interval(function() { if($scope.readyToLoad==true) { var windata = $scope.AAModuleData[$scope.wincount - 1]; slideId = windata.slideId; //use to skip last execution slide $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) { 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 = 320; $scope.jsPanelTop = $rootScope.cBModulejsPanelTop(); } else { $scope.jsPanelWidth = $(window).outerWidth() - 10; $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 }, }); //0.3 var aaViewElement = angular.element(document.getElementById("aaBodyView")); //0.4 for Opening module item, load it into image $scope.DisableUI(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); //Perform Activity as per SaveCb JSPanel //var max = $scope.GetAAwindowStoreData(windowviewid, 'maximised'); //var min = $scope.GetAAwindowStoreData(windowviewid, 'minimised'); var isMaximize = $scope.aaOpenInOtherModules.maximised; var isMinimize = $scope.aaOpenInOtherModules.minimised; if (isMaximize) { $scope.jsPanelAA.maximize(); $scope.SetAAwindowStoreData(windowviewid, 'maximised', true); $scope.SetAAwindowStoreData(windowviewid, 'minimised', false); } else if (isMinimize) { $scope.jsPanelAA.minimize(); $scope.SetAAwindowStoreData(windowviewid, 'minimised', true); $scope.SetAAwindowStoreData(windowviewid, 'maximised', false); } else { $scope.jsPanelAA.normalize(); $scope.SetAAwindowStoreData(windowviewid, 'maximised', false); $scope.SetAAwindowStoreData(windowviewid, 'minimised', false); } $scope.SetAAwindowStoreData(windowviewid, 'top', $scope.jsPanelTop); $scope.SetAAwindowStoreData(windowviewid, 'left', $scope.jsPanelLeft); $scope.SetAAwindowStoreData(windowviewid, 'width', $scope.jsPanelWidth); $scope.SetAAwindowStoreData(windowviewid, 'height', $scope.jsPanelHeight); $timeout(function () { $compile(aaViewElement.contents())($scope); $scope.setControlsIDs(windowviewid); $scope.loadbtnNavigator(windowviewid); if ($rootScope.isCallFromOtherModule) { $scope.JsPanelclick(windowviewid); } //if (document.getElementById('aaDetailPageDiv') != null) { if (document.getElementById('aaBodyView') != null) { //0.4 added some stylesheets if ($rootScope.isCallFromOtherModule) { var canvasDIvHeight = parseInt($('#AAImagePanel_' + windowviewid).outerHeight()) - 110; } 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); //$rootScope.canvasDivHeight = $('.jsPanel-content').height() - $('.main2 .stickey-area').height(); //$('.canvasDivClass').css("height", $rootScope.canvasDivHeight); $('.canvasDivClass').css("height", canvasDIvHeight); var OpenItemImagePath= $scope.GetAAwindowStoreData(windowviewid,'OpenItemImagePath'); var openedImage = new Image(); openedImage.id = 'modItemImage_'+windowviewid; openedImage.name = OpenItemImagePath; openedImage.onload = function () { $scope.imageWidth = this.width; $scope.imageHeight = this.height; $scope.currentTitleFromJson = $rootScope.getLocalStorageValue("currentViewTitle"); $("#modItemImage_" + windowviewid).attr('src', OpenItemImagePath); $rootScope.ViewImageWidth = $("#modItemImage_" + windowviewid).width(); $scope.ViewImageWidth = $("#modItemImage_" + windowviewid).width(); $scope.ViewImageHeight = $("#modItemImage_" + windowviewid).height(); $scope.relativeDimesion = 0; $("#modItemImage_" + windowviewid).css("width", $rootScope.ViewImageWidth + "px"); //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 = parseInt($scope.imageHeight + 10); canvas.width = parseInt($scope.imageWidth + 10); canvas.style.left = '0px'; canvas.style.top = '0px'; canvas.style.position = "absolute"; $("#canvasAADiv_" + windowviewid).append(canvas); $scope.context = canvas.getContext("2d") //6. Show all pins on AA opened item $scope.showAllPins(windowviewid); //$scope.showSelectedPins(windowviewid); $timeout(function () { //7. Highlight all system body list in left side $scope.highlightBodySystemList(windowviewid); $scope.Setslider(windowviewid); if ($rootScope.isCallFromOtherModule) { $scope.loadAAonCBData(windowviewid); } },1000); } openedImage.onerror = loadFailure; openedImage.src = OpenItemImagePath; } }, 400); } //Calling methode for save Js Panel Activity for SaveCB $scope.PanelActivity(); } $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) { 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); } } //, // change: function (event, ui) { // } }) .slider("pips", { rest: "label", step: "15" }); changeThumbnailSize(event, zoomLevel, windowviewid); } $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) { $("#navigatorBtn_" + windowviewid).on('click', function () { $("#navigatorDiv_" + windowviewid).toggle(); }); } $scope.JsPanelclick = function (windowviewid) { // call from while open module in CB $("#AAImagePanel_" + windowviewid).on('click', function (event) { var pnlName=event.currentTarget.id; $scope.$emit("cBEnableDisableMenuOption", 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); }); } 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"); relativeWidth = (scope.ViewImageWidth)*(value/100); relativeHeight = (scope.ViewImageHeight)*(value/100); // scope.sliderPercentValue = (value/100); $scope.SetAAwindowStoreData(windowviewid,'sliderPercentValue',(value/100)); $("#modItemImage_"+windowviewid).css("width", relativeWidth + "px"); $("#modItemImage_"+windowviewid).css("height", relativeHeight + "px"); $("#aaDetailViewCanvas_"+windowviewid).css("width", relativeWidth + "px"); $("#modItemImage_"+windowviewid).css("height", relativeHeight + "px"); $("#modItemImage_"+windowviewid).attr('src', ''); $("#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"; $("#canvasAADiv_" + windowviewid).append(canvas); scope.context = canvas.getContext("2d") var OpenItemImagePath= $scope.GetAAwindowStoreData(windowviewid,'OpenItemImagePath'); $("#modItemImage_"+windowviewid).attr('src', OpenItemImagePath); $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) { scope.showSelectedSystemPins($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("id"),windowviewid); } else { scope.showAllPins(windowviewid); } break; case "selectedPin_"+windowviewid: scope.showAllPins(windowviewid); setTimeout(function () { console.log(scope.allPinDataArray); scope.activePinOnSliderChange(windowviewid); }, 1000); 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); }); // $(document).on("click", "#" + $scope.jsPanelID +" .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function (event) { $(document).on("click", "#" + $scope.jsPanelID +" .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function () { // $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function () { $scope.setActiveTab(parseInt($rootScope.getLocalStorageValue("activeTab"))); $(".tools").css("z-index", "15000"); $rootScope.selectedBodySystemName = 'All'; $rootScope.selectedBodySystemId = 0; $rootScope.searchSelectedText = ''; }); }) // 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; 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}); } } $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', selectedPins); for (var i = 0; i < $scope.aaOpenInOtherModules.selectedCallouts.length; i++) { 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 }); } if($scope.aaOpenInOtherModules.showSelectedPins!=undefined) { //show selected pin $scope.activePinOnLayerChange(windowviewid); $scope.showSelectedPins(windowviewid); $timeout(function () { $scope.ShowCBAnnotation(windowviewid); }, 1000); } else if($scope.aaOpenInOtherModules.showAllPins!=undefined) { //Show all pins $scope.activePinOnLayerChange(windowviewid); $scope.showAllPinsAfterHide(windowviewid); $timeout(function () { $scope.ShowCBAnnotation(windowviewid); }, 500); } else if($scope.aaOpenInOtherModules.hideAllPins!=undefined) { //hide all pins $rootScope.hidePins(windowviewid); $timeout(function () { $scope.ShowCBAnnotation(windowviewid); }, 500); } } $scope.ShowCBAnnotation=function(windowviewid) { var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid,'CBselectedpinCordinate'); 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) { $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) { var imageName = $scope.GetAAwindowStoreData(windowviewid,'imageName'); $scope.SetAAwindowStoreData(windowviewid,'allPinDataArray',[]); var isSliderChange=$scope.GetAAwindowStoreData(windowviewid,'isSliderChange'); var promise = ModuleService.getPinDataForImage(imageName) .then( function (result) { //load navigator image if (result.data.Root._NavigatorImage != undefined) { document.getElementById("navimg_" + windowviewid).src = '~/../content/images/aa/images/navigator/' + result.data.Root._NavigatorImage; } else { document.getElementById("navimg_" + windowviewid).style.visibility = 'hidden'; document.getElementById("navigatorBtn_" + windowviewid).style.visibility = 'hidden'; document.getElementById("navigatorDiv_" + windowviewid).style.visibility = 'hidden'; } var aaPinData=result.data.Root.Item; $scope.SetAAwindowStoreData(windowviewid,'aaPinData',aaPinData); if (aaPinData != null && aaPinData.length > 0) { $rootScope.aaPinDataArray = aaPinData;// use at home var allPinDataArray=$scope.GetAAwindowStoreData(windowviewid,'allPinDataArray'); angular.forEach(aaPinData, function (value, key) { 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.loadSearchData(windowviewid); } else { $scope.EnableUI(); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); } } }, function (error) { console.log(' error in showAllPins: ' + error.statusText); } ) if (isSliderChange == true) { $timeout(function () { $scope.activePinOnLayerChange(windowviewid); }, 1000); } } $scope.FilterByImage = function (moduleId, query,windowviewid) { 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!'); } }, function (error) { // handle errors here 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 { $scope.SetAAwindowStoreData(windowviewid,'typeOfEvent',typeof event); var SelectedSystemID = event.currentTarget.id; var SelectedSystemTitle = event.currentTarget.title; if (event.currentTarget.title == "Current Structure") { } else { $scope.SetAAwindowStoreData(windowviewid,'clickedPins',[]); $scope.SetAAwindowStoreData(windowviewid, 'activePinArray', []); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); } 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(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $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(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); 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(); $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) }); //show annotation on first pin of the sysyem $scope.showAnnotation(selectedSystemPinData, 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 clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); angular.forEach(pinDataWithFirstTermNumber, function (value, key) { if (isBodySystemSelected == true) { clickedPins.push({ 'id': 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); } }) } $scope.EnableUI(); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); } $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"); // if ($scope.longestAnnotation.length <= 10) { // $("#"+speechbubbleDivId).css("width", "100px"); // } // else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) { // $("#"+speechbubbleDivId).css("width", "140px"); // } // else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) { // $("#"+speechbubbleDivId).css("width", "195px"); // } // else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) { // $("#"+speechbubbleDivId).css("width", "248px"); // } // else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) { // $("#"+speechbubbleDivId).css("width", "300px"); // } // else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) { // $("#"+speechbubbleDivId).css("width", "370px"); // } // else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) { // $("#"+speechbubbleDivId).css("width", "450px"); // } // else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) { // $("#"+speechbubbleDivId).css("width", "510px"); // } // else { // $("#"+speechbubbleDivId).css("width", ($scope.longestAnnotation.length) + "%"); // } } } 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 }); } } else { speechBubbleDimaensions.push( { "speechBuubleId": speechbubbleDivId, "speechBubbleLineId": speechBubbleLineDivId, "currentX": x, "currentY": y }); } 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 - 4) + '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( { drag: 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); } } }, }); $('.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(); //make all pin heads grey // var pinHeadName = 'PinArc_' + pinId; // 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).setLayer(pinHeadName, { // fillStyle: radial, // }).drawLayers(); }); //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) { if (clickedPin.event.ctrlKey == false) { $scope.SetAAwindowStoreData(windowviewid, 'clickedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); } 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 clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); for (var i = 0; i < pinWithSameTerm.length; i++) { clickedPins.push({ 'id': 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) { 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.$on('annotationToolEvent', function (event, data) { $('#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_'+$rootScope.MULTI_VIEW_ID).css("display", "block"); $('#canvasPaintAA_'+$rootScope.MULTI_VIEW_ID).css("display", "block"); $rootScope.onDrawingCanvasClick(); // $rootScope.FreeStylePaint(); }); $rootScope.loadSearchData = 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(); $rootScope.isLoading = false; $('#setting-spinner').css('visibility', 'hidden'); $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; } } } $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); $("#AABodySystems").empty(); $("#bodySystems").css("display", "none"); $("#AABodySystems").css("display", "block"); $("#bodySystemList_" + windowviewid + " li a").each(function (key, value) { var $systemOptions = $('').appendTo("#AABodySystems") $compile($systemOptions)($scope); }); } }, 500); } }) }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } $scope.$on('listManagerEvent', function (event, data) { $("#viewName").empty(); var windowviewid= $rootScope.MULTI_VIEW_ID; var currentView = $rootScope.getLocalStorageValue("currentViewTitle"); var viewNmeHtml = '' $('#viewName').append(viewNmeHtml); $scope.EnableUI(); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); if ($rootScope.bodySystemSeletedId == null) { $rootScope.loadSearchData(windowviewid); } else { $rootScope.refreshTermListOnAASystemSelection($rootScope.bodySystemSeletedId,windowviewid); } $timeout(function () { $("#totalTerms").empty(); $("#totalTerms").html("" + $("#termList option").length + " Structures"); }, 1000); }); $rootScope.refreshTermListOnAASystemSelection = function (bodySystemId,windowviewid) { if(windowviewid==undefined) //body system change from list manager at home windowviewid= $rootScope.MULTI_VIEW_ID; $rootScope.bodySystemSeletedId = bodySystemId; $("#AABodySystems").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); $("#AABodySystems").find("option[id=" + bodySystemId + "]").css({ "background-color": "#3399FF", "color": "#ffffff" }); $('#termList').empty(); var bodySystemName = $("#AABodySystems #" + bodySystemId).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.hidePins = function (windowviewid) { $scope.ToolBoxStyle("HidePin",windowviewid); $scope.DisableUI(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $scope.hideSpeechBubble(windowviewid); $scope.SetAAwindowStoreData(windowviewid, 'isShowBodyWithCBPinData', 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(); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); } $scope.showAllPinsAfterHide = function (windowviewid) { $scope.ToolBoxStyle("ShowAllPin",windowviewid); $scope.DisableUI(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $scope.SetAAwindowStoreData(windowviewid,'isHidePinBtnClicked',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); if ($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title") == "Current Structure" || $("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title") == undefined) { var isSliderChange=$scope.GetAAwindowStoreData(windowviewid,'isSliderChange'); if (isSliderChange == true) { isSliderChange = false; $scope.showAllPins(windowviewid); } } $scope.SetAAwindowStoreData(windowviewid, 'isShowBodyWithCBPinData', true); }; $scope.showSelectedPins = function (windowviewid) { $scope.ToolBoxStyle("ShowSelectedPin",windowviewid); $("#listManager").css("display", "none"); $("#optionsListManagerTab").removeClass("active"); $scope.DisableUI(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $scope.SetAAwindowStoreData(windowviewid, 'isShowBodyWithCBPinData', false); $scope.SetAAwindowStoreData(windowviewid,'isHidePinBtnClicked',false); 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(); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); } $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.loadSearchData(windowviewid); if (AAPinTermData.length > 0) { $scope.showItemsForSearch(event); } } // if ($rootScope.isSearchInputClicked == true) { // $rootScope.isSearchInputClicked = false; // $rootScope.searchListArray = []; // $("#backdrop > #searchListDivAA > #termlistfilter_" + windowviewid + " > li").each(function (key, value) { // $rootScope.searchListArray.push({ "name": $(this).find("a").html(), "id": $(this).find("a").attr("id") }); // }); // } }, 500); } $scope.HideSearchList = function () { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $timeout(function () { $("#termlistfilter_"+windowviewid).css("display", "none"); }, 1000); } $scope.highlightPinBasedOnSerachItem = function (id,windowviewid) { if(windowviewid==undefined) // call also from also home controller list manager windowviewid= $rootScope.MULTI_VIEW_ID; $scope.showAllPinsAfterHide(windowviewid); $scope.searchItemText = $("#" + id).val(); $rootScope.searchSelectedText = $("#" + id).val(); $('#termList option[selected="selected"]').prop("selected", false); $('#termList option[value="' + $rootScope.searchSelectedText + '"]').prop("selected", true); $("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); $('#termList option[value="' + $rootScope.searchSelectedText + '"]').css({ "background-color": "#3399FF", "color": "#ffffff" }); $("#termlistfilter_" + windowviewid + " li").find("a").css({ "background-color": "#ffffff", "color": "#000000" }); $("#termlistfilter_" + windowviewid + " li").find("a[id=" + id + "]").css({ "background-color": "#3399FF", "color": "#ffffff" }); $scope.searchFilter = $("#" + id).val(); $('#selectedTermName_' + windowviewid).val(); $('#selectedTermName_' + windowviewid).attr("placeholder", "search... "); //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); } $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]; var btnStrutureBoxname = document.getElementById("comment-box_"+windowviewid).name; if (btnStrutureBoxname == "showAnnotationText") { $("#comment-box_"+windowviewid).addClass("disableAnnotationText"); document.getElementById("comment-box_"+windowviewid).name = "hideAnnotationText"; } else { $("#comment-box_"+windowviewid).removeClass("disableAnnotationText"); document.getElementById("comment-box_"+windowviewid).name = "showAnnotationText"; } $scope.ShowHideAnnotationText(windowviewid); } $scope.ShowHideAnnotationText = function(windowviewid) { var btnStrutureBoxname = document.getElementById("comment-box_"+windowviewid).name; var speechBubbleDimaensions=$scope.GetAAwindowStoreData(windowviewid,'speechBubbleDimaensions'); if (btnStrutureBoxname == "showAnnotationText") { for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { $("#" + speechBubbleDimaensions[i].speechBuubleId).css("display", "block"); $("#" + speechBubbleDimaensions[i].speechBubbleLineId).css("display", "block"); } } else { 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 () { $("#" + $scope.jsPanelID).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); } }); $("#" + $scope.jsPanelID).draggable({ stop: function (event, ui) { var len = (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len - 1]; //var offSets = $(this).offset(); var postions = (this).position(); (this).offsetTop (this).offsetLeft $scope.SetAAwindowStoreData(windowviewid, 'top', ui.position.top); $scope.SetAAwindowStoreData(windowviewid, 'left', ui.position.left); } }); $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function (event) { var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id'); var len = (currentPanelId).split("_").length; var windowviewid = (currentPanelId).split("_")[len - 1]; for (var i in $rootScope.AAWindowData) { if ($rootScope.AAWindowData[i] !== null && typeof ($rootScope.AAWindowData[i]) == "object") { if ($rootScope.AAWindowData[i].multiwinid == windowviewid) { $rootScope.AAWindowData.splice(i, 1); } } } //$(".tools").css("z-index", "15000"); }); $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-max .jsglyph-maximize", function (event) { var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id'); var len = (currentPanelId).split("_").length; var windowviewid = (currentPanelId).split("_")[len - 1]; $scope.SetAAwindowStoreData(windowviewid, 'maximised', true); $scope.SetAAwindowStoreData(windowviewid, 'minimised', false); }); $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-min #minSpan", function (event) { var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id'); var len = (currentPanelId).split("_").length; var windowviewid = (currentPanelId).split("_")[len - 1]; $scope.SetAAwindowStoreData(windowviewid, 'maximised', false); $scope.SetAAwindowStoreData(windowviewid, 'minimised', true); }); $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-norm .jsglyph-normalize", function (event) { var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id'); var len = (currentPanelId).split("_").length; var windowviewid = (currentPanelId).split("_")[len - 1]; $scope.SetAAwindowStoreData(windowviewid, 'maximised', false); $scope.SetAAwindowStoreData(windowviewid, 'minimised', false); }); } }]); 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 () { 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.hidePins(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.showAllPinsAfterHide(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(id,windowviewid) { console.log('AA hide search is called'); var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.highlightPinBasedOnSerachItem(id,windowviewid); }); } 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.showSelectedPins(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('tools1'); $("#selectedTermName_"+windowviewid).parent().parent().parent().parent().parent().toggleClass('active'); }