'use strict'; AIA.controller("TileViewListController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "DataService", "ModuleService","$interval","$filter", function ($scope, $window, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, BodyRegions, BodySystems, ViewOrientations, ImageTypes, DataService, ModuleService, $interval, $filter) { $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) { if(tabToSet=="" ||tabToSet==undefined) { $scope.activeTab=1; } else { $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.ObjectAttribute=function(windowviewid) { var windata={ 'multiwinid' : windowviewid, 'moduleName':'', 'currentViewTitle':'', 'parentSlugName':'', 'sliderPercentValue':1, 'imageId':'', 'imageName':'', 'bodySystemName':'', 'OpenItemImagePath':'', 'isBodySystemSelected':false, 'isSelectedPinBtnClickedAftrSliderCange':false, 'isHidePinBtnClicked':false, 'isSliderChange':false, 'clickedPins':[], 'activePinArray':[], 'typeOfEvent':'', 'selectedSystemName':null, 'SelectedSystemID':0, 'aaPinData':[], 'allPinDataArray':[], 'selectedSystemPinData':[], 'AAPinTermData':[], 'pinTermData':[], 'sliderVal':100, 'speechBubbleDimaensions':[], 'isShowBodyWithCBPinData':false, 'CBselectedpinCordinate': [], 'verticalScroll': 0, 'horizontalScroll':0, 'y': 0, 'x': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': true, 'minmaxAutoEvent':true, 'id': 0, 'selectedPins': [], 'isShowSelectedPins': false, 'selectedSearchId': 0, 'isShowAllPins': false, 'canvasImageWidth': 0, 'canvasImageHeight': 0, 'navigatorImage':"", 'showHideAnnotations': 'showAnnotationText', 'annotationData':{shapeStates:[],paintCanvasState:[]}, 'totalstructure': 0, 'totalstructureLm': 0, 'intervalObject': null, 'SearchTimeStampValue': 0, 'keyctrl': false, }; return windata; } $scope.initializeAAWindowData = function(windowviewid,isOpenWithExistsModule,openPanelNo){ if (isOpenWithExistsModule || openPanelNo == 0) { if ($rootScope.AAWindowData != undefined) { $rootScope.AAWindowData.length = 0; } else { $rootScope.AAWindowData = []; } $rootScope.AAWindowData.push($scope.ObjectAttribute(windowviewid)); } else { var isNewWindow=true; for (var k = 0; k < $rootScope.AAWindowData.length; k++) { if ($rootScope.AAWindowData[k].multiwinid == windowviewid) { isNewWindow=false; break; } } if(isNewWindow) { $rootScope.AAWindowData.push($scope.ObjectAttribute(windowviewid)); } } } $scope.GetAAwindowStoreData=function(windowviewid,keyname){ for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { return $rootScope.AAWindowData[x][keyname]; } } } $scope.SetAAwindowStoreData=function(windowviewid,keyname,value){ for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { $rootScope.AAWindowData[x][keyname]=value; } } } // access from home controller //get data of AA module $rootScope.GetAAwindowData=function(windowviewid,keyname) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { return $rootScope.AAWindowData[x][keyname]; } } } // access from home controller $rootScope.SetAAwindowData=function(windowviewid,keyname,data) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ if($rootScope.AAWindowData[x].multiwinid==windowviewid) { $rootScope.AAWindowData[x][keyname]=data; } } } $scope.DisableAAUI = function (windowviewid) { var modulePanel = $("#AAImagePanel_"+windowviewid).find(" .jsPanel-content"); if(modulePanel.length>0) { modulePanel[0].style.pointerEvents="none"; modulePanel[0].style.opacity="0.7"; } $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); // CB module disable all $('#HomeContainerDiv').css('pointer-events', 'none'); $('#HomeContainerDiv').css('opacity', '0.7'); } $scope.EnableAAUI = function (windowviewid) { var modulePanel = $("#AAImagePanel_"+windowviewid).find(" .jsPanel-content"); if(modulePanel.length>0) { modulePanel[0].style.pointerEvents="auto"; modulePanel[0].style.opacity="1"; } $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); // CB module enable all $('#HomeContainerDiv').css('pointer-events', 'auto'); $('#HomeContainerDiv').css('opacity', '1'); } $scope.loadForModuleById = function (moduleId) { $rootScope.isCallFromOtherModule = undefined; $rootScope.MULTI_VIEW_ID += 1 $scope.DisableAAUI($rootScope.MULTI_VIEW_ID); // store exist module in module service var ExistData = ModuleService.getModuleData("ATLAS_ANATOMY"); if (ExistData != undefined && ExistData.length > 0) { // clear all module data before open new module in cb ModuleService.ClearWinDataByModule(ExistData.mType); } var newWindowData = { "mType": 'ATLAS_ANATOMY', }; ModuleService.setModuleData(newWindowData, 0); // close/remove prev panel when in minimised mode if($rootScope.AAWindowData!=undefined) { if($rootScope.AAWindowData.length>0) { for(var x=0 ;x < $rootScope.AAWindowData.length;x++){ var winid=$rootScope.AAWindowData[x].multiwinid; if ($('#AAImagePanel_' + winid).html() != undefined) { $('#AAImagePanel_' + winid).remove(); } } $rootScope.AAWindowData=[]; } } $scope.initializeAAWindowData($rootScope.MULTI_VIEW_ID,true,undefined); $rootScope.openModules.push({ "ModuleId": 2 }); if ($rootScope.refreshcheck == null) { $location.path('/'); } var curtab = $rootScope.getLocalStorageValue("activeTab"); $scope.setActiveTab(curtab) console.log('loadForModuleById is called') $scope.SetAAwindowStoreData($rootScope.MULTI_VIEW_ID,'moduleName',"ATLAS_ANATOMY"); $rootScope.currentActiveModuleTitle = "ATLAS_ANATOMY"; $scope.AllBodyRegion = BodyRegions; $scope.AllBodySystem = BodySystems; $scope.AllOrientation = ViewOrientations; $scope.AllImageType = ImageTypes; if (localStorage.getItem("CurrentBodyRegion") != '') { $("#region option[value='" + localStorage.getItem('CurrentBodyRegion') + "']").prop('selected', true); } if (localStorage.getItem("CurrentBodySystem") != '') { $("#system option[value='" + localStorage.getItem('CurrentBodySystem') + "']").prop('selected', true); } if (localStorage.getItem("CurrentOrientation") != '') { $("#orientation option[value='" + localStorage.getItem('CurrentOrientation') + "']").prop('selected', true); } if (localStorage.getItem("CurrentImageType") != '') { $("#Type option[value='" + localStorage.getItem('CurrentImageType') + "']").prop('selected', true); } $scope.query.selectedbodyregion = localStorage.getItem('CurrentBodyRegion'); $scope.query.selectedbodysystem = localStorage.getItem('CurrentBodySystem'); $scope.query.selectedorientation = localStorage.getItem('CurrentOrientation'); $scope.query.selectedimagetype = localStorage.getItem('CurrentImageType'); $scope.FilterByImage(1, $scope.query,$rootScope.MULTI_VIEW_ID); setTimeout(function () { if ($('#grid-view').css("display") == "block") { if ($rootScope.getLocalStorageValue('AAGridViewHighlightThumbnail') !== null) { $('#' + $rootScope.getLocalStorageValue("AAGridViewHighlightThumbnail")).find('.thumbnail').addClass('HightLightThumbnail'); } if ($rootScope.getLocalStorageValue('AAGridViewScroll') !== null && $location.url() == "/tile-view-list") { $("#grid-view").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"); } } }, 100); } $scope.openModuleItemView = function ($event) { var windowviewid = $rootScope.MULTI_VIEW_ID; $rootScope.MenuModuleName = "AA"; //0. Get selected Image Id if ($scope.isListViewButtonClicked == true) { if ($scope.isOpenBtnClicked == true) { var moduleItemDataToBeSaved = $("#demoText").text().trim(); var moduleItemDataToBeSavedID = $event.target.id; $scope.isOpenBtnClicked = false; } else { var moduleItemDataToBeSavedID = $event.currentTarget.id; localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID); var moduleItemDataToBeSaved = $("#list-view table tbody #" + moduleItemDataToBeSavedID).find('td:eq(0)').text().trim(); } } else { var moduleItemDataToBeSavedID = $event.currentTarget.id; localStorage.setItem("listViewSelectedID", moduleItemDataToBeSavedID); var moduleItemDataToBeSaved = $("#list-view table tbody #" + moduleItemDataToBeSavedID).find('td:eq(0)').text().trim(); $scope.isListViewButtonClicked = false; } // open module bu openresource var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource'); if (isopenResourceRequest == "true") { //set default module data var AAopenData = { "id": moduleItemDataToBeSavedID, "mType": 'ATLAS_ANATOMY', "showAllPins":true, "windowTitle": moduleItemDataToBeSaved, "scaleIndex":100, "size": { height: 600, width: 900 }, "position": { x: 1, y: 30 } }; window.parent.AIAModuleOpenResourceInfo(AAopenData); } else { //1.Filter selected module ietem data and get the pushed opened moduile array object var OpenedTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData); //2. Pick the image name to create a source to open $scope.SetAAwindowStoreData(windowviewid, 'imageId', OpenedTileData[0]); $scope.SetAAwindowStoreData(windowviewid, 'imageName', OpenedTileData[3]); var imageName = OpenedTileData[3]; $scope.SetAAwindowStoreData(windowviewid, 'bodySystemName', OpenedTileData[2]); var OpenItemImagePath = "../../../content/images/aa/images/" + OpenedTileData[3]; $scope.SetAAwindowStoreData(windowviewid, 'OpenItemImagePath', OpenItemImagePath); $rootScope.listArray.push({ "imageName": OpenItemImagePath, "text": moduleItemDataToBeSaved }); //3. set opened module item ti localStorage.setItem("currentViewTitle", OpenedTileData[6]); if ($('#grid-view').css("display") == "block") { localStorage.setItem("AAGridViewScroll", $("#grid-view").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("
" + MultipleLanguage + "
"); } } else { console.log('MultiLanguageAnnationArray.length is :' + $scope.MultiLanguageAnnationArray.length) } if ($scope.longestAnnotation != null || $scope.longestAnnotation != undefined) { $("#"+speechbubbleDivId).css("min-width", "auto"); $("#"+speechbubbleDivId).css("white-space", "nowrap"); } } var speechBubbleDims = []; var speechBubbleDimaensions=$scope.GetAAwindowStoreData(windowviewid,'speechBubbleDimaensions'); if(speechBubbleDimaensions.length>0) { var ismatch=false; for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { if (speechBubbleDimaensions[i].speechBuubleId == speechbubbleDivId) { speechBubbleDimaensions[i].speechBubbleLineId =speechBubbleLineDivId; speechBubbleDimaensions[i].currentX =x; speechBubbleDimaensions[i].currentY =y; ismatch=true; } } if(ismatch==false) { speechBubbleDimaensions.push( { "speechBuubleId": speechbubbleDivId, "speechBubbleLineId": speechBubbleLineDivId, "currentX": x, "currentY": y, "pinId": PinId }); } } else { speechBubbleDimaensions.push( { "speechBuubleId": speechbubbleDivId, "speechBubbleLineId": speechBubbleLineDivId, "currentX": x, "currentY": y, "pinId": PinId }); } speechBubbleDims.push({ currentX: x, currentY: y }); document.getElementById(speechBubbleLineDivId).style.display = 'block'; document.getElementById(speechBubbleLineDivId).style.left = ((speechBubbleDims[0].currentX - 12)) + 'px'; var sliderVal=$scope.GetAAwindowStoreData(windowviewid,'sliderVal'); if (sliderVal == 25) { document.getElementById(speechBubbleLineDivId).style.top = ((speechBubbleDims[0].currentY + 5)) + 'px'; } else { document.getElementById(speechBubbleLineDivId).style.top = ((speechBubbleDims[0].currentY)) + 'px'; } document.getElementById(speechbubbleDivId).style.display = 'block'; document.getElementById(speechbubbleDivId).style.left = (speechBubbleDims[0].currentX +20) + 'px'; document.getElementById(speechbubbleDivId).style.top = (speechBubbleDims[0].currentY) + 'px'; if (isShowBodyWithCBPinData == true) { document.getElementById(speechbubbleDivId).style.left = (lx) + 'px'; document.getElementById(speechbubbleDivId).style.top = (ly) + 'px'; var bubble = document.getElementById(speechbubbleDivId); var bulleleft=bubble.offsetLeft; var bulletop=bubble.offsetTop; var sppechBubbleId = PinId +'_'+windowviewid; var speechBubbleDraggedLineID = "speechBubbleDraggedLine" + sppechBubbleId; $("#speechBubbleLine" + sppechBubbleId).css("visibility", "hidden"); $("#speechBubbleLine" + sppechBubbleId).css("display", "none"); for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { if (speechBubbleDimaensions[i].speechBuubleId == speechbubbleDivId) { speechBubbleDimaensions[i].speechBubbleLineId =speechBubbleDraggedLineID; $scope.angle(speechBubbleDraggedLineID, speechBubbleDimaensions[i].currentX, speechBubbleDimaensions[i].currentY, bulleleft + 20, bulletop + 20, true,windowviewid); } } } } $('.common-drag').draggable( { containment: '#canvasAADiv_' + windowviewid, drag: function (evt) { //stop: function (evt) { var clickedSpeechBubbleId = $(this).attr("id"); var len= (clickedSpeechBubbleId).split("_").length; var windowviewid = (clickedSpeechBubbleId).split("_")[len-1]; var verticalScrollPosition = document.getElementById('canvasAADiv_'+windowviewid).scrollTop; var horizontlScrollPosition = document.getElementById('canvasAADiv_' + windowviewid).scrollLeft; var leftpos=evt.pageX + horizontlScrollPosition - $('#canvasAADiv_' + windowviewid).offset().left; var toptpos=evt.pageY + verticalScrollPosition - $('#canvasAADiv_' + windowviewid).offset().top; if(leftpos<5 || toptpos<5) { evt.preventDefault(); } //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, leftpos,toptpos, true, windowviewid); } } }, stop: function (evt) { var clickedSpeechBubbleId = $(this).attr("id"); var len = (clickedSpeechBubbleId).split("_").length; var windowviewid = (clickedSpeechBubbleId).split("_")[len - 1]; var sppechBubbleId = $(this).attr("id").substring(12); var PinId = sppechBubbleId.split("_")[0]; $rootScope.UnsaveCurriculum = true; $timeout(function () { var CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); var BubleObj = document.getElementById(clickedSpeechBubbleId); var CBselectedpinCordinate = new jinqJs() .from(CBselectedpinCordinate) .update(function (coll, index) { coll[index].lx = BubleObj.offsetLeft; coll[index].ly = BubleObj.offsetTop; }) .at("pinId == " + PinId); }, 100); } }); $('.crossDiv_temp').on('click', function (evt) { var imgId = $(this).attr("id"); var len= (imgId).split("_").length; var windowviewid = (imgId).split("_")[len-1]; var imgDivId=(imgId).split("_")[0]; var pinId = imgDivId.substring(8, imgDivId.length); $('#speechBubble' + pinId+'_'+windowviewid).remove(); $("#speechBubbleDraggedLine" + pinId+'_'+windowviewid).remove(); $("#speechBubbleLine" + pinId + '_' + windowviewid).remove(); var CBselectedpinCordinate = []; CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); CBselectedpinCordinate = new jinqJs() .from(CBselectedpinCordinate) .delete().at("pinId == " + pinId).select(); $scope.SetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate', CBselectedpinCordinate); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); clickedPins = new jinqJs() .from(clickedPins) .delete().at("id == " + pinId).select(); $scope.SetAAwindowStoreData(windowviewid, 'clickedPins', clickedPins); var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); const index = activePinArray.indexOf("PinArc_"+pinId); if (index > -1) { activePinArray.splice(index, 1); } $scope.GetAAwindowStoreData(windowviewid,'activePinArray',activePinArray); $rootScope.UnsaveCurriculum = true; }); //make the head green var radialAfterClick = $('#aaDetailViewCanvas_'+windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(126, 187, 83)' }); var pinHeadName = 'PinArc_' + PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinHeadName, { fillStyle: radialAfterClick, }).drawLayers(); var typeOfEvent=$scope.GetAAwindowStoreData(windowviewid,'typeOfEvent'); if (typeOfEvent == "string") { var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); for (var i = 0; i <= clickedPins.length - 1; i++) { var pinHeadName = 'PinArc_' + clickedPins[i].id; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinHeadName, { fillStyle: radialAfterClick, }).drawLayers(); } } } $scope.angle = function (dragLineId, cx, cy, ex, ey, BoolValues,windowviewid) { var dy = ey - cy; var dx = ex - cx; var theta = 0; if (dx < 0) { theta = Math.atan(dy / dx) * (180 / Math.PI); theta = theta + 180; } else if (dy < 0) { theta = Math.atan(dy / dx) * (180 / Math.PI); theta = theta + 360; } else { theta = Math.atan(dy / dx) * (180 / Math.PI); } var d = Math.sqrt((cx - ex) * (cx - ex) + (cy - ey) * (cy - ey)); var e = cy; var f = cx; if (BoolValues == true) { var sliderVal=$scope.GetAAwindowStoreData(windowviewid,'sliderVal'); if (sliderVal == 40) { $("#" + dragLineId).css({ 'display': 'block', 'width': d + 'px', 'top': (e - 5) + 'px', 'left': (f - 5) + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } else if (sliderVal == 25) { $("#" + dragLineId).css({ 'display': 'block', 'width': d + 'px', 'top': (e - 2) + 'px', 'left': (f - 2) + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } else { $("#" + dragLineId).css({ 'display': 'block', 'width': d + 'px', 'top': (e - 10) + 'px', 'left': (f - 5) + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } } else { $("#bord_annotation").css({ 'display': 'block', 'width': d + 'px', 'top': e + 'px', 'left': f + 'px', 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%' }); } } $scope.drawStaticPinsOnImage = function (canvasId, PinId, offsetX1, offsetY1, x, y,windowviewid) { var slidpercentValue= $scope.GetAAwindowStoreData(windowviewid,'sliderPercentValue'); var multipliedByValue = 5; var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { multipliedByValue = 10; } console.log('isSliderrChange') var radial = $('#' + canvasId).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#' + canvasId).drawLine({ layer: true, name: "Pin_" + PinId, groups: ["Pin_" + PinId], strokeStyle: '#565656', strokeWidth: 2, visible: true, x1: offsetX1 * slidpercentValue, y1: offsetY1 * slidpercentValue, x2: x * slidpercentValue, y2: y * slidpercentValue, }).drawArc({ name: "PinArc_" + PinId, layer: true, groups: ["Pin_" + PinId], strokeStyle: 'grey', strokeWidth: 2, visible: true, fillStyle: radial, x: x * slidpercentValue, y: y * slidpercentValue, radius: 10, click: function (clickedPin) { $rootScope.UnsaveCurriculum =true; $('#selectedTermName_' + windowviewid).val(''); $("#selectedTermName_" + windowviewid).attr("name", '0'); //birendra var iskeyctrlActive= $scope.GetAAwindowStoreData(windowviewid, 'keyctrl');//for iPad // for mac os Command key use for multi selection if (clickedPin.event.ctrlKey == false && clickedPin.event.metaKey == false && !iskeyctrlActive) { $scope.SetAAwindowStoreData(windowviewid, 'clickedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); $scope.SetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate', []); $scope.SetAAwindowStoreData(windowviewid,'activePinArray',[]); } var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); var isFound = jQuery.inArray(clickedPin.name, activePinArray) if (isFound == -1) { activePinArray.push(clickedPin.name); var pinID = (clickedPin.name).substring(7, (clickedPin.name).length); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var pinData = new jinqJs() .from(aaPinData) .where("_PinId == " + pinID) .select(); var pinTermNumber = pinData[0]._TermId; var pinWithSameTerm = new jinqJs() .from(aaPinData) .where("_TermId == " + pinTermNumber) .select(); if (pinWithSameTerm != undefined && pinWithSameTerm != null && pinWithSameTerm.length > 0) { var selectedPins = $scope.GetAAwindowStoreData(windowviewid, 'selectedPins'); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); for (var i = 0; i < pinWithSameTerm.length; i++) { clickedPins.push({ 'id': pinWithSameTerm[i]._PinId }); selectedPins.push(pinWithSameTerm[i]._PinId); //some time get multiple pinid on selected termid var pinvalue='PinArc_' + pinWithSameTerm[i]._PinId; var isFound = jQuery.inArray(pinvalue, activePinArray) if (isFound == -1) { activePinArray.push(pinvalue); } var headX = (parseInt(pinWithSameTerm[i]._HeadX)); var headY = (parseInt(pinWithSameTerm[i]._HeadY)); //Save Cordinate for show annotation as per Pin var CBselectedpinCordinate = $scope.GetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate'); CBselectedpinCordinate.push( { "hy": headY, "ly": headY+10, "hx": headX, "lx": headX+30, "pinId": pinWithSameTerm[i]._PinId }); } } $scope.SetAAwindowStoreData(windowviewid,'isSelectedPinBtnClickedAftrSliderCange',false); var selectedPinData = new jinqJs() .from(aaPinData) .where("_PinId == " + pinID) .select(); if (clickedPin.event.ctrlKey == true||clickedPin.event.metaKey == true ||iskeyctrlActive) { 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 { var radial = $('#aaDetailViewCanvas_' + windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(216, 216, 216)' }); $('#aaDetailViewCanvas_' + windowviewid).setLayers({ fillStyle: radial, }).drawLayers(); //change the head color to green var radialAfterClick = $('#aaDetailViewCanvas_' + windowviewid).createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'rgb(126, 187, 83)' }); clickedPin.fillStyle = radialAfterClick; $scope.showAnnotation(selectedPinData, false, true, false,false, windowviewid); } } } }).drawLayers(); } $scope.getMousePos = function (evt) { return { x: Math.round(evt.pageX - $('#canvasDiv').offset().left), y: Math.round(evt.pageY - $('#canvasDiv').offset().top) } } $scope.removePin = function (canvasId, pinId,windowviewid) { var pinName = 'Pin_' + pinId; var pinArcName = 'PinArc_' + pinId; $('#' + canvasId).removeLayer(pinName).drawLayers(); $('#' + canvasId).removeLayer(pinArcName).drawLayers(); $scope.removeSpeechBubble(windowviewid); } $rootScope.aaAnnotationToolEvent = function (windowviewid) { $('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(255,255,255)") $('#editstylebackgroundcolor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" }); $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(0,0,0)") $('#outlineColor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" }); $('#canvasAA_'+windowviewid).css("display", "block"); $('#canvasPaintAA_'+windowviewid).css("display", "block"); } //Reload Body View after setting Change $rootScope.reloadAABodyViewEvent = function (isLexiconChange, windowviewid) { $scope.loadaaBodyViewChangedBySetting(windowviewid,isLexiconChange); } $scope.loadaaBodyViewChangedBySetting = function (windowviewid, isLexiconChange) { $scope.DisableAAUI(windowviewid); // 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); var timeintval=$scope.SetAAwindowStoreData(windowviewid,'intervalObject'); if(isLexiconChange) { // remove first annotation text $scope.removeSpeechBubble(windowviewid); //load term data and also language data $rootScope.loadPinSearchData(windowviewid); timeintval = $interval(function(){loadaaBodyViewBySetting(windowviewid)},5); $scope.SetAAwindowStoreData(windowviewid,'intervalObject',timeintval); function loadaaBodyViewBySetting(panid) { var pinTermData = $scope.GetAAwindowStoreData(panid, 'pinTermData'); if (pinTermData!=null) { var intval=$scope.GetAAwindowStoreData(panid,'intervalObject'); $scope.stopVocab(intval); $scope.langSearchLoad(panid); $scope.SetAAwindowStoreData(panid,'isShowBodyWithCBPinData',true); //loading annotation $scope.ShowCBAnnotation(panid); $timeout(function () { if ($rootScope.isListManagerMenuSelected) { var selectedPanel = $("#viewName option:selected").val(); var winid = (selectedPanel).split("_")[1]; if(winid==panid) { $scope.DisableAAUI(panid); $rootScope.aalistManagerEvent(panid); } } }, 200); $scope.EnableAAUI(panid); } else { console.log("waiting for search term Data"); } } $scope.stopVocab = function (intvalobj) { if (angular.isDefined(intvalobj)) { $interval.cancel(intvalobj); intvalobj = undefined; } }; } } $rootScope.aaloadSearchData = function (windowviewid) { var imageId= $scope.GetAAwindowStoreData(windowviewid,'imageId'); $scope.SetAAwindowStoreData(windowviewid,'pinTermData',[]); var promise = ModuleService.getTermTextDataForAAImage(imageId) .then( function (response) { var AAPinTermData = response.data.PinTermData.TermData; $scope.SetAAwindowStoreData(windowviewid,'AAPinTermData',AAPinTermData) $scope.EnableAAUI(windowviewid); $rootScope.loadPinSearchData(windowviewid); }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } $rootScope.loadPinSearchData = function (windowviewid) { var AAPinTermData= $scope.GetAAwindowStoreData(windowviewid,'AAPinTermData') for (var i = 0; i <= $rootScope.lexiconLanguageArray.length - 1; i++) { var lexiconId = $rootScope.lexiconLanguageArray[i].id; var matchedLanguageTermData = new jinqJs() .from(AAPinTermData) .where('_LanguageId == ' + lexiconId) .select(); if(matchedLanguageTermData.length>0) { if(i==0) { $scope.SetAAwindowStoreData(windowviewid, 'pinTermData', matchedLanguageTermData); } else { var pinTermData = $scope.GetAAwindowStoreData(windowviewid, 'pinTermData'); var result=pinTermData.concat(matchedLanguageTermData); $scope.SetAAwindowStoreData(windowviewid, 'pinTermData', result); } } } } //event remove it fire multiple time $rootScope.aalistManagerEvent=function(windowviewid){ $scope.DisableAAUI(windowviewid); $("#langaugeDivLm").css("display", "none"); $("#AABodySystems").empty(); $("#bodySystems").css("display", "none"); $("#langaugeDivLm").css("display", "none"); $("#AABodySystems").css("display", "block"); $('#termList').empty(); var totalstructure=0; $rootScope.isListManagerMenuSelected = true; $scope.SetAAwindowStoreData(windowviewid,'totalstructureLm',0); var languageArray = $rootScope.lexiconLanguageArray; if(languageArray.length>1) { $("#langaugeDivLm").css("display", "block"); $("#selectLanguageLm").empty(); for (var i = 0; i <= languageArray.length - 1; i++) { $('#selectLanguageLm').append(''); } } var $all = $('').appendTo('#AABodySystems'); $compile($all)($scope); $("#bodySystemList_" + windowviewid + " li a").each(function (key, value) { if($(this).attr('id')!="0") { var sysid= $(this).attr('id') + '_' +windowviewid; if ($(this).parent().hasClass("disabledSelectedSystem")) { var $systemOptions = $('').appendTo("#AABodySystems") $compile($systemOptions)($scope); } else{ var $systemOptions = $('').appendTo("#AABodySystems") $compile($systemOptions)($scope); } } }); // primary language var langId=languageArray[0].id; $scope.loadaaListManger(windowviewid,langId,totalstructure); } $rootScope.changeLanguageLmEventAA = function (windowviewid) { $scope.DisableAAUI(windowviewid); $('#termList').empty(); var totalstructure=0; $scope.SetAAwindowStoreData(windowviewid,'totalstructure',0); var langIdvalue = $("#selectLanguageLm option:selected").val(); setTimeout(function () { if(langIdvalue!=undefined) { var selectedLanguage = new jinqJs() .from( $rootScope.lexiconLanguageArray) .where('id == ' + langIdvalue) .select()[0]; var langId=selectedLanguage.id; } else { var langId=$rootScope.lexiconLanguageArray[0].id; } var sysid = $("#AABodySystems option:selected").attr("id"); var bodysystemId = (sysid).split("_")[0]; if(bodysystemId=="0") { $scope.loadaaListManger(windowviewid,langId,totalstructure); } else { $scope.aasystemMatchTermLoad(bodysystemId,windowviewid,langId,totalstructure); } },100) } $rootScope.LoadMoreLmEventAA = function (windowviewid) { $scope.DisableAAUI(windowviewid); var langIdvalue = $("#selectLanguageLm option:selected").val(); var totalstructure = $scope.GetAAwindowStoreData(windowviewid, 'totalstructureLm'); setTimeout(function () { if(langIdvalue!=undefined) { var selectedLanguage = new jinqJs() .from( $rootScope.lexiconLanguageArray) .where('id == ' + langIdvalue) .select()[0]; var langId=selectedLanguage.id; } else { var langId=$rootScope.lexiconLanguageArray[0].id; } var sysid = $("#AABodySystems option:selected").attr("id"); var bodysystemId = (sysid).split("_")[0]; if(bodysystemId=="0") { $scope.loadaaListManger(windowviewid,langId,totalstructure); } else { $scope.aasystemMatchTermLoad(bodysystemId,windowviewid,langId,totalstructure); } }, 100); } $scope.loadaaListManger = function (windowviewid,langId,totalstructure) { var selectedpinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData');//term data for selected language var languageTermDataArray = new jinqJs() .from( selectedpinTermData) .where('_LanguageId == ' + langId) .select(); var afterskipdata = new jinqJs() .from(languageTermDataArray) .skip(totalstructure) .select(); var limitTofilterdata = $filter('limitTo')(afterskipdata, 500); var matchTermDataFilter = new jinqJs() .from(limitTofilterdata) .distinct('_TermText', '_TermNumber') .orderBy([{ field: '_TermText', sort: 'asc' }]) .select('_TermNumber', '_TermText'); var option=''; angular.forEach(matchTermDataFilter, function (value2, key2) { totalstructure=totalstructure+1; option=option+''; }) var $el = $(option).appendTo('#termList') $compile($el)($scope); $scope.SetAAwindowStoreData(windowviewid,'totalstructureLm',totalstructure); var termsTotal = '' + totalstructure + ' Structures'; $("#totalTermsLm").empty(); $("#totalTermsLm").append(termsTotal); if(totalstructure < languageTermDataArray.length) { $("#totalTermsLm").append(''); } else { $("#totalTermsLm").append(''); $('#btlLoadMoreLm').attr('disabled', 'disabled'); } $scope.EnableAAUI(windowviewid); } $rootScope.refreshTermListOnAASystemSelection = function (selectedBodysystemId) { var windowviewid = (selectedBodysystemId).split("_")[1]; var bodysystemId = (selectedBodysystemId).split("_")[0]; $("#AABodySystems").find("option:not(:disabled)").css({ "background-color": "#ffffff", "color": "#000000" }); $("#AABodySystems").find("option[id=" + selectedBodysystemId + "]").css({ "background-color": "#3399FF", "color": "#ffffff" }); $('#termList').empty(); // var bodySystemName = $("#AABodySystems #" + selectedBodysystemId).val(); $scope.SetAAwindowStoreData(windowviewid, 'totalstructureLm',0); var totalstructure = 0; var langIdvalue = $("#selectLanguageLm option:selected").val(); if(langIdvalue!=undefined) { var selectedLanguage = new jinqJs() .from( $rootScope.lexiconLanguageArray) .where('id == ' + langIdvalue) .select()[0]; var langId=selectedLanguage.id; } else { var langId=$rootScope.lexiconLanguageArray[0].id; } if(bodysystemId=="0") { setTimeout(function () { $scope.loadaaListManger(windowviewid,langId,totalstructure); }, 100); } else { $scope.aasystemMatchTermLoad(bodysystemId,windowviewid,langId,totalstructure); } } $scope.aasystemMatchTermLoad=function(bodysystemId,windowviewid,langId,totalstructure) { var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var systemMatchedTermList = new jinqJs() .from(aaPinData) .where('_BodySystemId == ' + bodysystemId) .select(); if (systemMatchedTermList != null || systemMatchedTermList != undefined) { $scope.refreshTerms(systemMatchedTermList,windowviewid,langId,totalstructure); } } $scope.refreshTerms = function (termList,windowviewid,langId,totalstructure) { var matchTermData = []; var selectedpinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData'); var languageTermDataArray = new jinqJs() .from( selectedpinTermData) .where('_LanguageId == ' + langId) .select(); for (var i = 0; i < termList.length; i++) { var actulaTerm = new jinqJs() .from(languageTermDataArray) .where('_TermNumber == ' + termList[i]._TermId) .select()[0]; if (actulaTerm != null || actulaTerm != undefined) { matchTermData.push( { "_TermNumber": actulaTerm._TermNumber, "_TermText": actulaTerm._TermText }); } } var matchTermDataFilter = new jinqJs() .from(matchTermData) .distinct('_TermText', '_TermNumber') .orderBy([{ field: '_TermText', sort: 'asc' }]) .select('_TermNumber', '_TermText'); var option=''; if (matchTermDataFilter != null || matchTermDataFilter != undefined) { angular.forEach(matchTermDataFilter, function (value2, key2) { totalstructure=totalstructure+1; option=option+''; }) var $el = $(option).appendTo('#termList') $compile($el)($scope); $scope.SetAAwindowStoreData(windowviewid,'totalstructureLm',totalstructure); var termsTotal = '' + totalstructure + ' Structures'; $("#totalTermsLm").empty(); $("#totalTermsLm").append(termsTotal); if(totalstructure < matchTermDataFilter.length) { $("#totalTermsLm").append(''); } else { $("#totalTermsLm").append(''); $('#btlLoadMoreLm').attr('disabled', 'disabled'); } } $scope.EnableAAUI(windowviewid); } $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo,windowviewid) { var languageArray = $rootScope.lexiconLanguageArray; var pinTermData = $scope.GetAAwindowStoreData(windowviewid, 'pinTermData'); if (pinTermData != null || pinTermData != undefined) { var matchedTermNoData = new jinqJs() .from(pinTermData) .where('_TermNumber == ' + actualTermNo) .select(); if (matchedTermNoData != null || matchedTermNoData != undefined) { for (var j = 0; j <= languageArray.length - 1; j++) { $scope.matchedLanguageTermNoData = new jinqJs() .from(matchedTermNoData) .where('_LanguageId == ' + languageArray[j].id) .select(); var termText = $scope.matchedLanguageTermNoData[0]._TermText; $scope.MultiLanguageAnnationArray.push(termText); }; } } } $rootScope.hidePinsevent = function (windowviewid) { $rootScope.UnsaveCurriculum = true; $rootScope.hidePins(windowviewid); } $rootScope.hidePins = function (windowviewid) { $scope.ToolBoxStyle("HidePin",windowviewid); $scope.DisableAAUI(windowviewid); $scope.hideSpeechBubble(windowviewid); $scope.SetAAwindowStoreData(windowviewid, 'isShowSelectedPins', false); $scope.SetAAwindowStoreData(windowviewid, 'isShowAllPins', false); $scope.SetAAwindowStoreData(windowviewid, 'isHidePinBtnClicked', true); var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); angular.forEach(aaPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue._PinId; var pinArcName = 'PinArc_' + aaPinDataValue._PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: false // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: false // set to true instead to show the layer again }).drawLayers(); }) $scope.EnableAAUI(windowviewid); } $scope.showAllPinEvent = function (windowviewid) { $rootScope.UnsaveCurriculum = true; $scope.showAllPinsAfterHide(windowviewid); } $scope.showAllPinsAfterHide = function (windowviewid) { $scope.ToolBoxStyle("ShowAllPin",windowviewid); $scope.DisableAAUI(windowviewid); $scope.SetAAwindowStoreData(windowviewid, 'isShowAllPins', true); $scope.SetAAwindowStoreData(windowviewid,'isHidePinBtnClicked',false); $scope.SetAAwindowStoreData(windowviewid, 'isShowSelectedPins', false); var selectedSystemName=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemName'); if (selectedSystemName != null && selectedSystemName != undefined) { var selectedSystemPinData=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemPinData'); $scope.showSystemPins(selectedSystemPinData, false,windowviewid); } else { var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); $scope.showSystemPins(aaPinData, false,windowviewid); } $scope.showSpeechBubble(windowviewid); var isSliderChange = $scope.GetAAwindowStoreData(windowviewid, 'isSliderChange'); if ($("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title") == "Current Structure" || $("#bodySystemList_" + windowviewid + " li.activeAASystemSelect a").attr("title") == undefined) { if (isSliderChange == true) { $scope.showAllPins(windowviewid); } } else if (isSliderChange) { $scope.showAllPins(windowviewid); } }; $scope.showSelectedPinEvent = function (windowviewid) { $rootScope.UnsaveCurriculum = true; $scope.showSelectedPins(windowviewid); } $scope.showSelectedPins = function (windowviewid) { $scope.ToolBoxStyle("ShowSelectedPin",windowviewid); $("#listManager").css("display", "none"); $("#optionsListManagerTab").removeClass("active"); $scope.DisableAAUI(windowviewid); var isHidePinBtnClicked = $scope.GetAAwindowStoreData(windowviewid, 'isHidePinBtnClicked'); if (isHidePinBtnClicked) { $scope.showAllPins(windowviewid); setTimeout(function () { $scope.activePinOnSliderChange(windowviewid); }, 200); } $scope.SetAAwindowStoreData(windowviewid, 'isShowAllPins', false); $scope.SetAAwindowStoreData(windowviewid, 'isHidePinBtnClicked', false); $scope.SetAAwindowStoreData(windowviewid, 'isShowSelectedPins', true); var selectedSystemName=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemName'); if (selectedSystemName != null && selectedSystemName != undefined) { var selectedSystemPinData=$scope.GetAAwindowStoreData(windowviewid,'selectedSystemPinData'); $scope.showSystemPins(selectedSystemPinData, true,windowviewid); } else { var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); $scope.showSystemPins(aaPinData, true,windowviewid); } $scope.showSpeechBubble(windowviewid); var isSelectedPinBtnClickedAftrSliderCange= $scope.GetAAwindowStoreData(windowviewid,'isSelectedPinBtnClickedAftrSliderCange'); if (isSelectedPinBtnClickedAftrSliderCange == true) { var activePinArray=$scope.GetAAwindowStoreData(windowviewid,'activePinArray'); for (var i = 0; i <= activePinArray.length - 1; i++) { var pinName = activePinArray[i].split("_"); var activePinName = 'Pin_' + pinName[1]; var pinArcName = 'PinArc_' + pinName[1]; $('#aaDetailViewCanvas_'+windowviewid).setLayer(activePinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); } } }; $scope.showSystemPins = function (seletedSystemPinData, isShowSelectedPins, windowviewid) { if (isShowSelectedPins) { var selectedPins = []; $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); var clickedPins=$scope.GetAAwindowStoreData(windowviewid,'clickedPins'); angular.forEach(clickedPins, function (value, key) { seletedSystemPinData = new jinqJs() .from(seletedSystemPinData) .where('_PinId != ' + value.id) .select(); selectedPins.push(value.id); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', selectedPins); }); angular.forEach(clickedPins, function (value1, key1) { // if (aaPinDataValue._PinId != value.id) { var pinName = 'Pin_' + value1.id; var pinArcName = 'PinArc_' + value1.id; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); // } }) angular.forEach(seletedSystemPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue._PinId; var pinArcName = 'PinArc_' + aaPinDataValue._PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: false // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: false // set to true instead to show the layer again }).drawLayers(); }) } else { angular.forEach(seletedSystemPinData, function (aaPinDataValue, aaPinDataKey) { var pinName = 'Pin_' + aaPinDataValue._PinId; var pinArcName = 'PinArc_' + aaPinDataValue._PinId; $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinName, { visible: true // set to true instead to show the layer again }).drawLayers(); $('#aaDetailViewCanvas_'+windowviewid).setLayer(pinArcName, { visible: true // set to true instead to show the layer again }).drawLayers(); }) } $scope.EnableAAUI(windowviewid); } $scope.showItemsForSearch = function (windowviewid, isbuttionclick) { if ($('#searchListDivAA_' + windowviewid).html() != "") $('#termlistfilter_'+windowviewid).empty(); $scope.IsSearchVisible = true; // clear time stamp on text box click $scope.SetAAwindowStoreData(windowviewid, 'SearchTimeStampValue', 0); var langIdvalue = $("#searchLanguageLm_"+windowviewid+" option:selected").val(); if(langIdvalue!=undefined) { var selectedLanguage = new jinqJs() .from( $rootScope.lexiconLanguageArray) .where('id == ' + langIdvalue) .select()[0]; var langId=selectedLanguage.id; } else { // get default language var langId=$rootScope.lexiconLanguageArray[0].id } var selectedpinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData');//term data for selected language var languageTermDataArray = new jinqJs() .from( selectedpinTermData) .where('_LanguageId == ' + langId) .select(); var searchvalue = $("#selectedTermName_" + windowviewid).val(); var searchfilterdata = $filter('filter')(languageTermDataArray, searchvalue); if(searchvalue.trim()!="") { searchfilterdata = $filter('orderBy')(searchfilterdata, '_TermText.length'); } else { searchfilterdata = $filter('orderBy')(searchfilterdata, '_TermText'); } $scope.limitTofilterdata = $filter('limitTo')(searchfilterdata, 500); $('#termlistfilter_'+windowviewid).css("display", "block"); angular.forEach($scope.limitTofilterdata, function (value2, key2) { var $el = $('').appendTo('#termlistfilter_' + windowviewid); $compile($el)($scope); }) var $all = $('#termlistfilter_'+windowviewid).appendTo('#searchListDivAA_' + windowviewid); $compile($all)($scope); if(isbuttionclick) { $timeout(function () { $('#termlistfilter_'+windowviewid).focus(); }, 200); } } $scope.resetSearchListView = function (event) { var len = (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len - 1]; var date = new Date(); var newtimestamp = date.getTime(); var oldtimestamp = $scope.GetAAwindowStoreData(windowviewid, 'SearchTimeStampValue'); if ((newtimestamp - oldtimestamp) > 100) { $scope.SetAAwindowStoreData(windowviewid, 'SearchTimeStampValue', newtimestamp); $scope.showFilteredTerms(windowviewid); } } $scope.HideSearchList = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $timeout(function () { if(!$scope.IsSearchVisible) { $("#termlistfilter_" + windowviewid).empty(); $("#termlistfilter_" + windowviewid).css("display", "none"); } }, 600); } $scope.showFilteredTerms = function (windowviewid) { var langIdvalue = $("#searchLanguageLm_"+windowviewid+" option:selected").val(); if(langIdvalue!=undefined) { var selectedLanguage = new jinqJs() .from( $rootScope.lexiconLanguageArray) .where('id == ' + langIdvalue) .select()[0]; var langId=selectedLanguage.id; } else { // get default language var langId=$rootScope.lexiconLanguageArray[0].id } var selectedpinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData');//term data for selected language var languageTermDataArray = new jinqJs() .from( selectedpinTermData) .where('_LanguageId == ' + langId) .select(); var searchvalue = $("#selectedTermName_" + windowviewid).val(); var searchfilterdata = $filter('filter')(languageTermDataArray, searchvalue); if(searchvalue.trim()!="") { searchfilterdata = $filter('orderBy')(searchfilterdata, '_TermText.length'); } else { searchfilterdata = $filter('orderBy')(searchfilterdata, '_TermText'); } $scope.limitTofilterdata = $filter('limitTo')(searchfilterdata, 20); $('#termlistfilter_'+windowviewid).css("display", "block"); $('#termlistfilter_'+windowviewid).empty(); angular.forEach($scope.limitTofilterdata, function (value2, key2) { var $el = $('').appendTo('#termlistfilter_' + windowviewid); $compile($el)($scope); }) var $all = $('#termlistfilter_'+windowviewid).appendTo('#searchListDivAA_' + windowviewid); $compile($all)($scope); $("#selectedTermName_" + windowviewid).attr("name", "0"); }; $scope.changeaaSearchLanguage = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $scope.changeSearchText(windowviewid); } $scope.changeSearchText = function (windowviewid) { setTimeout(function () { var term_num = $("#selectedTermName_" + windowviewid).attr("name"); if(term_num!=undefined && term_num!="0") { var langIdvalue = $("#searchLanguageLm_"+windowviewid+" option:selected").val(); if(langIdvalue!=undefined) { var selectedLanguage = new jinqJs() .from( $rootScope.lexiconLanguageArray) .where('id == ' + langIdvalue) .select()[0]; var langId=selectedLanguage.id; } else { var langId=$rootScope.lexiconLanguageArray[0].id; } var selectedpinTermData=$scope.GetAAwindowStoreData(windowviewid,'pinTermData');//term data for selected language var languageTermDataArray = new jinqJs() .from( selectedpinTermData) .where('_LanguageId == ' + langId) .select(); var selectedTerm = new jinqJs() .from( languageTermDataArray) .where('_TermNumber == '+term_num) .select()[0]; if(selectedTerm!=undefined) { $("#selectedTermName_" + windowviewid).attr("name", selectedTerm._TermNumber); $("#selectedTermName_" + windowviewid).val(selectedTerm._TermText); } else { $("#selectedTermName_" + windowviewid).attr("name", "0"); $("#selectedTermName_" + windowviewid).val(''); } } else { $("#selectedTermName_" + windowviewid).attr("name", "0"); $("#selectedTermName_" + windowviewid).val(''); } },100) } $scope.highlightPinBasedOnSerachItemEvent = function (termid,isTermListOptionClicked) { $rootScope.UnsaveCurriculum = true; $scope.highlightPinBasedOnSerachItem(termid,isTermListOptionClicked); } $scope.highlightPinBasedOnSerachItem = function (termid,isTermListOptionClicked) { var windowviewid = (termid).split("_")[1]; var TermNumber= termid.split('_')[0]; var currenttermidTxt = $('#' + termid).text(); $scope.IsSearchVisible=false; if (isTermListOptionClicked == true) { $('#selectedTermName_' + windowviewid).val(''); $("#selectedTermName_" + windowviewid).attr("name", '0'); } else { $('#selectedTermName_' + windowviewid).val(currenttermidTxt); $("#selectedTermName_" + windowviewid).attr("name", TermNumber); $("#termlistfilter_" + windowviewid).empty(); $("#termlistfilter_" + windowviewid).css("display", "none"); } $scope.showAllPinsAfterHide(windowviewid); $("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); $("#termList").find("option[id=" + termid + "]").css({ "background-color": "#3399FF", "color": "#ffffff" }); //get data from pindata for this trem var aaPinData = $scope.GetAAwindowStoreData(windowviewid,'aaPinData'); var pinDataForTerm = new jinqJs() .from(aaPinData) .where("_TermId == " + TermNumber) .select(); // 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(); $scope.SetAAwindowStoreData(windowviewid,'clickedPins',[]); $scope.SetAAwindowStoreData(windowviewid, 'selectedPins', []); $scope.SetAAwindowStoreData(windowviewid,'activePinArray',[]); //clear all cb data $scope.SetAAwindowStoreData(windowviewid, 'CBselectedpinCordinate', []); $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.MultipleAnnotation = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; //set true to false or vice versa var iskeyctrlActive= $scope.GetAAwindowStoreData(windowviewid, 'keyctrl'); $("#multiannotation_" + windowviewid).toggleClass("disableAAMultiAnnotationText"); if(iskeyctrlActive) { $("#multiannotation_"+windowviewid ).attr('title', 'Active Multiple Structure'); } else { $("#multiannotation_"+windowviewid ).attr('title', 'Disable Multiple Structure'); } $scope.SetAAwindowStoreData(windowviewid, 'keyctrl', !iskeyctrlActive); } $scope.ShowHideAnnotation = function (event) { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $rootScope.UnsaveCurriculum = true; var btnStrutureBoxname = document.getElementById("comment-box_"+windowviewid).name; $("#comment-box_" + windowviewid).toggleClass("disableAAAnnotationText"); if (btnStrutureBoxname == "showAnnotationText") { $("#comment-box_"+windowviewid ).attr('title', 'Show Structure Name Boxes'); $("#comment-box_"+windowviewid +" i").removeClass("far fa-comment-alt-times").addClass("far fa-comment-alt"); $("#comment-box_"+windowviewid ).attr('name', 'hideAnnotationText'); $scope.SetAAwindowStoreData(windowviewid, 'showHideAnnotations', 'hideAnnotationText'); } else { $("#comment-box_"+windowviewid ).attr('title', 'Hide Structure Name Boxes'); $("#comment-box_"+windowviewid +" i").removeClass("far fa-comment-alt").addClass("far fa-comment-alt-times"); $("#comment-box_"+windowviewid ).attr('name', 'showAnnotationText'); $scope.SetAAwindowStoreData(windowviewid, 'showHideAnnotations', 'showAnnotationText'); } $scope.ShowHideAnnotationText(windowviewid); } $scope.ShowHideAnnotationText = function(windowviewid) { var showHideAnnotations = $scope.GetAAwindowStoreData(windowviewid, 'showHideAnnotations'); document.getElementById("comment-box_"+windowviewid).name = showHideAnnotations; var speechBubbleDimaensions=$scope.GetAAwindowStoreData(windowviewid,'speechBubbleDimaensions'); if (showHideAnnotations == "showAnnotationText") { for (var i = 0; i <= speechBubbleDimaensions.length - 1; i++) { $("#" + speechBubbleDimaensions[i].speechBuubleId).css("display", "block"); $("#" + speechBubbleDimaensions[i].speechBubbleLineId).css("display", "block"); } } else { $("#comment-box_"+windowviewid).addClass("disableAAAnnotationText"); 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(); } } } //Created method by Sandeep for Save JSPanel Activity on the CB module $scope.PanelActivity = function () { $(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function (event) { var panelid = $(event.target).parent().parent().parent().parent().attr('id'); $scope.RemoveJSPanel(panelid); $scope.setActiveTab(parseInt($rootScope.getLocalStorageValue("activeTab"))); $(".tools").css("z-index", "15000"); }); } $scope.RemoveJSPanel = function (panelid) { var len = (panelid).split("_").length; var windowviewid = (panelid).split("_")[len - 1]; // remove old stored data after close panel for (var index = 0 ; index < $rootScope.AAWindowData.length; index++) { if ($rootScope.AAWindowData[index].multiwinid == windowviewid) { if (index != -1) { // remove module which one is loaded $rootScope.AAWindowData.splice(index, 1); if ($('#' + panelid).html() != undefined) { $('#' + panelid).remove(); } // $rootScope.resetjsPanelTop(panelid); } } } } }]); function refreshTermListOnSystemSel(bodySystemId) { var windowviewid = (bodySystemId).split("_")[1]; var rootScope = angular.element(document.getElementById("aaDetailPageDiv_"+windowviewid)).scope(); rootScope.$apply(function () { rootScope.refreshTermListOnAASystemSelection(bodySystemId); }); } function showSelectedSystemPins(event) { console.log('OnBodySystem chnaged is called outside '); var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { //select system and its related pins scope.showSelectedSystemPins(event); }); } function hidePins(event) { var len= (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len-1]; var rootScope = angular.element(document.getElementById("aaBodyView")).scope(); rootScope.$apply(function () { rootScope.hidePinsevent(windowviewid); //Calling for Save CB Window data //rootScope.updateWindowsContentForSaveCB(); }); } function showAllPins(event) { var len= (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len-1]; var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.showAllPinEvent(windowviewid); }); } function onSearchAA(event) { console.log('AA search is called') var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; if((event.currentTarget.id).match('btnSearchAA')) scope.showItemsForSearch(windowviewid,true); else { scope.showItemsForSearch(windowviewid,false); } }); } function changeaaSearchLanguage(event) { event.stopPropagation(); var scope = angular.element(document.getElementsByClassName("aaBodyView")).scope(); scope.$apply(function () { scope.changeaaSearchLanguage(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 resetSearchListView(event) { console.log('AA keyup search is called') var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.resetSearchListView(event); }); } function onSearchItemSelection(termid, isTermListOptionClicked) { console.log('AA hide search is called'); var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.highlightPinBasedOnSerachItemEvent(termid,isTermListOptionClicked); }); } function showHideAnnotation(event) { var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.ShowHideAnnotation(event); }); } function keyControlAAActive(event) { var scope = angular.element(document.getElementById("aaBodyView")).scope(); scope.$apply(function () { scope.MultipleAnnotation(event); }); } function showSelectedPins(event) { console.log('showSelectedPins is called') var scope = angular.element(document.getElementById("aaBodyView")).scope(); var len= (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[len-1]; scope.$apply(function () { scope.showSelectedPinEvent(windowviewid); }); } function openModuleItemView(event) { var scope = angular.element(document.getElementById("list-view")).scope(); scope.isListViewButtonClicked = true; scope.$apply(function () { scope.openModuleItemView(event); }); } function openListViewModuleItem(event) { var scope = angular.element(document.getElementById("list-view")).scope(); scope.isListViewButtonClicked = true; scope.$apply(function () { scope.openListViewModuleItem(event); }); } function openCurrentView(event) { var scope = angular.element(document.getElementById("list-view")).scope(); scope.isListViewButtonClicked = true; scope.isOpenBtnClicked = true; scope.$apply(function () { scope.openModuleItemView(event); }); } function systemChange(event) { event.stopPropagation(); var len= (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len-1]; $("#bodySystemList_" + windowviewid ).toggle(); var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { $(".custom-tooltip").toggle(); } } //sidebar toggle function SideBarToggleAA(event) { var len = (event.currentTarget.id).split("_").length; var windowviewid = (event.currentTarget.id).split("_")[len - 1]; $("#" + event.currentTarget.id).parent().toggleClass('active'); $("#selectedTermName_"+windowviewid).parent().parent().parent().parent().parent().toggleClass('active'); }