'use strict'; AIA.controller("TileViewListController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "DataService", "ModuleService", function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, BodyRegions, BodySystems, ViewOrientations, ImageTypes, DataService, ModuleService) { $rootScope.OpenedTileData = []; var ATLAS_ANATOMY = 'Atlas Anatomy'; var CLINICAL_ILLUSTRATION = 'Clinical Illustrations'; var CLINICAL_ANIMATION = 'Clinical Animations'; $rootScope.closeBtnImgPath = "~/../content/images/speeachBubbleClose.png"; //variables to bind Filter by Controls $scope.searchAAListViewData = []; $scope.SelectedAAthumbImage = []; $scope.SelectedAAImage = []; $scope.SelectedAASummary = []; $scope.SelectedAAId = []; $scope.SelectedAATitle = []; $scope.selectedAAListViewData = []; $scope.filterstring = false; $scope.AllBodyRegion = []; $scope.AllBodySystem = []; $scope.AllOrientation = []; $scope.AllImageType = []; $scope.query = { selectedbodyregion: '', selectedbodysystem: '', selectedorientation: '', selectedimagetype: '', }; $scope.loadForModuleById = function (moduleId) { $scope.moduleId = moduleId; console.log('loadForModuleById is called') $rootScope.moduleName = Modules[moduleId].Name; $scope.AllBodyRegion = BodyRegions; $scope.AllBodySystem = BodySystems; $scope.AllOrientation = ViewOrientations; $scope.AllImageType = ImageTypes; var promise = ModuleService.loadModuleDataBasedOnModuleName($scope.moduleName) .then( function (result) { $scope.moduleLandingData = result; //console.log(JSON.stringify(result, null, 4)); }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } $scope.openModuleItemView = function (event) { //0. Get selected Image Id var moduleItemDataToBeSaved = event.target.id; //1.Filter selected module ietem data and get the pushed opened moduile array object $rootScope.OpenedTileData = ModuleService.GetOpenedTileData(moduleItemDataToBeSaved, $scope.moduleLandingData); //2. Pick the image name to create a source to open $rootScope.imageName = $rootScope.OpenedTileData[3]; $rootScope.OpenItemImagePath = "../../../content/images/aa/images/" + $rootScope.OpenedTileData[3]; //3. set opened module item title localStorage.setItem("currentViewTitle", $rootScope.OpenedTileData[6]); //3. Navigate to the Module-item-view var u = $location.url(); $location.url('/module-item-view'); } $scope.openModuleItem = function () { var jsContentURL; var moduleItemViewDivId; //1. create a jsPanel and load the module item view if ($rootScope.moduleName == ATLAS_ANATOMY) { jsContentURL = 'app/views/aa/atlas-anatomy-detail.html'; moduleItemViewDivId = 'aaDetailPageDiv'; } else if ($rootScope.moduleName == CLINICAL_ANIMATION) { //to do, in next phase of project } else if ($rootScope.moduleName == CLINICAL_ILLUSTRATION) { //to do, in next phase of project } $.jsPanel({ id: 'ImagePanel', selector: '.aaBodyView', theme: 'success', currentController: 'TileViewListController', parentSlug: 'tile-view', ajax: { url: jsContentURL }, title: localStorage.getItem("currentViewTitle"), position: { top: 70, left: 1, }, size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, }); console.log('jsPanel loaded ImagePanel exist= ' + document.getElementById('ImagePanel')) //0.3 var aaViewElement = angular.element(document.getElementById(moduleItemViewDivId)); //0.4 for Opening module item, load it into image var openedImage = new Image(); openedImage.name = $rootScope.OpenItemImagePath; openedImage.onload = getImageHeightWidth; openedImage.onerror = loadFailure; openedImage.src = $rootScope.OpenItemImagePath; $timeout(function () { $compile(aaViewElement.contents())($scope); if (document.getElementById('aaDetailPageDiv') != null) { //0.4 added some stylesheets $('#aaBodyView').css("height", $(window).outerHeight()); $('#aaBodyView').css("width", $(window).outerWidth()); $scope.currentTitleFromJson = localStorage.getItem("currentViewTitle"); $("#modItemImage").attr('src', $rootScope.OpenItemImagePath); //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'; canvas.height = parseInt(($scope.imageHeight)); canvas.width = parseInt($scope.imageWidth); canvas.style.left = '0px'; canvas.style.top = '0px'; canvas.style.position = "absolute"; $("#imageDiv").append(canvas); $scope.context = canvas.getContext("2d") //6. Show all pins on AA opened item $scope.showAllPins(); } }, 1050); } function loadFailure() { console.log('unable to load opened module ietem'); return true; } function getImageHeightWidth() { $scope.imageWidth = this.width; $scope.imageHeight = this.height; } angular.element(document).ready(function (e) { $("#ImagePanel").resize(function () { $("#imageDiv").scrollLeft($rootScope.CanvasDivLeftPosition); $("#imageDiv").scrollTop($rootScope.CanvasDivTopPosition); }); }) $scope.showAllPins = function () { var promise = ModuleService.getPinDataForImage($rootScope.imageName) .then( function (result) { $scope.aaPinData = result.data.Root.Item; angular.forEach($scope.aaPinData, function (value, key) { //CREATING PIN WITHOUT CANAVS //var ax = value._PinX; //var ay = value._PinY; //var bx = value._HeadX; //var by = value._HeadY; //if (ax > bx) { // bx = ax + bx; // ax = bx - ax; // bx = bx - ax; // by = ay + by; // ay = by - ay; // by = by - ay; //} //console.log('ax: ' + ax); //console.log('ay: ' + ay); //console.log('bx: ' + bx); //console.log('by: ' + by); //var angle = Math.atan((ay - by) / (bx - ax)); //console.log('angle: ' + angle); //angle = (angle * 180 / Math.PI); //console.log('angle: ' + angle); //angle = -angle; //console.log('angle: ' + angle); //var length = Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by)); //console.log('length: ' + length); //var style = "" //style += "left:" + (ax) + "px;" //style += "top:" + (ay) + "px;" //style += "width:" + length + "px;" //style += "height:1px;" //style += "background-color:black;" //style += "position:absolute;" //style += "transform:rotate(" + angle + "deg);" //style += "-ms-transform:rotate(" + angle + "deg);" //style += "transform-origin:0% 0%;" //style += "-moz-transform:rotate(" + angle + "deg);" //style += "-moz-transform-origin:0% 0%;" //style += "-webkit-transform:rotate(" + angle + "deg);" //style += "-webkit-transform-origin:0% 0%;" //style += "-o-transform:rotate(" + angle + "deg);" //style += "-o-transform-origin:0% 0%;" //style += "-webkit-box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, .1);" //style += "box-shadow: 0px 0px 2px 2px rgba(0, 0, 0, .1);" //style += "z-index:99;" //$("
").appendTo('#imageDiv'); //END $scope.context.beginPath(); $scope.context.moveTo(value._PinX, value._PinY); $scope.context.lineTo(value._HeadX, value._HeadY); $scope.context.stroke(); var headX = (parseInt(value._HeadX)) - 20; var headY = (parseInt(value._HeadY)) - 15; var img = new Image(); img.src = "~/../../../content/images/noraml-pin.png"; img.onload = function () { $scope.context.drawImage(img, headX, headY); } }) console.log(JSON.stringify(result, null, 4)); }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } $scope.FilterByImage = function (moduleId, query) { //alert(JSON.stringify(query)); $scope.moduleId = moduleId; console.log('loadForModuleById is called') $rootScope.moduleName = Modules[moduleId].Name; 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($scope.moduleName) .then( function (result) { // alert(JSON.stringify($scope.moduleLandingData)); $scope.moduleLandingData = result; $scope.selectedAAListViewData = new jinqJs() .from($scope.moduleLandingData.data.root.Item) //.orderBy([{ field: '_Title', sort: 'asc' }]) .select(); $('#grid-view').empty(); //alert(JSON.stringify($scope.selectedAAListViewData)) 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 = $('
' + '
' + '' + '

' + value._Title + '

').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 }); } }); //Show Error Message in case of gridview if no data is found if ($scope.searchCIListViewData.length == 0) { var $el = $('
No illustration found for the selected search criteria!
').appendTo('#grid-view'); $compile($el)($scope); } console.log(JSON.stringify(result, null, 4)); }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } $scope.Reset = function (moduleId, query) { 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", ''); //localStorage.setItem("CISelectedRowId", ""); //localStorage.setItem("CIListViewScroll", ''); if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); } $('#ListViewDiv').scrollTop(0); // $scope.HideListViewDiv(); $scope.filterstring = false; //while ($scope.searchCIListViewData.length) { // $scope.searchCIListViewData.pop(); //} $scope.FilterByImage(1, query); } $scope.showSelectedSystemPins = function (event) { //1.Remove all the pins first $scope.ClearAllPins(); var selectedSystemName = event.currentTarget.title; //2. get pinData var promise = ModuleService.getPinDataForImage($rootScope.imageName) .then( function (result) { $scope.aaPinData = result.data.Root.Item; //3. get termText info var promise = ModuleService.getTermTextForPin($scope.moduleName) .then( function (response) { $scope.TermInfo = response.data.Terms.Term; //on gettng all required data, draw pins var selectedSystemPinData = new jinqJs() .from($scope.aaPinData) .where("_BodySystemName == " + selectedSystemName) .select(); angular.forEach(selectedSystemPinData, function (value, key) { $scope.context.beginPath(); $scope.context.moveTo(value._PinX, value._PinY); $scope.context.lineTo(value._HeadX, value._HeadY); $scope.context.stroke(); var headX = (parseInt(value._HeadX)) - 20; var headY = (parseInt(value._HeadY)) - 15; var img = new Image(); img.src = "~/../../../content/images/noraml-pin.png"; img.onload = function () { $scope.context.drawImage(img, headX, headY); } }) //show annotation on first pin of the sysyem $scope.showAnnotation(selectedSystemPinData); }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) console.log(JSON.stringify(result, null, 4)); }, function (error) { // handle errors here console.log(' error: ' + error.statusText); } ) } $scope.showAnnotation = function (selectedSystemPinData) { var firstPinId = selectedSystemPinData[0]._PinId; var pinTermNumber = selectedSystemPinData[0]._TermId; //check if other pin have same termNumber var pinDataWithFirstTermNumber = new jinqJs() .from($scope.aaPinData) .where("_TermId == " + pinTermNumber) .select(); var termTextdata = new jinqJs() .from($scope.TermInfo) .where("__ActualTermNumber == " + pinTermNumber) .select(); var termText = termTextdata[0].__TermText; $scope.MultiLanguageAnnationArray = []; $scope.MultiLanguageAnnationArray.push(termText); angular.forEach(pinDataWithFirstTermNumber, function (value, key) { var headX = (parseInt(value._HeadX)); var headY = (parseInt(value._HeadY)); $scope.createSpeechBubble(headX, parseInt(headY),value._PinId); // alert('headX: ' + headX + ', headY: ' + headY + ',termText: ' + termText); }) } $scope.ClearAllPins = function () { var canvasHeight = document.getElementById('aaDetailViewCanvas').height; var canvasWidth = document.getElementById('aaDetailViewCanvas').width; $scope.context.clearRect(0, 0, canvasWidth, canvasHeight); }; $scope.createSpeechBubble = function (x, y, PinId) { //1. In transparency box we shows two annotation at a time, so we need to decide the max length of annotation in btween two annotation because based on that // we decide the size of speech bubble $scope.longestAnnotation = $scope.MultiLanguageAnnationArray.reduce(function (firstAnnotation, seconAnnotation) { return firstAnnotation.length > seconAnnotation.length ? firstAnnotation : seconAnnotation; }); $scope.createSpeechBubbleBasedOnAnnotationLengthwithoutCtrl(x, y,PinId); //2. //if (event.ctrlKey) { // console.log('ctrl pressed'); // $scope.multiAnnotationIsON = true; // //2.1 create unique speech bubbles // $scope.speechBubbleCounter = $scope.speechBubbleCounter + 1; // var id = "speechBubble" + $scope.speechBubbleCounter; // //2.2 Get clicked locationa and find if it is already clicked earlier too on same location // var pointClicked = parseInt(x) + parseInt(y); // var isClickedOnSamePoint = $("#canvasDiv").find("div[id=" + pointClicked + "]").length; // console.log('isClickedOnSamePoint: ' + isClickedOnSamePoint); // // if user has not clciked on smae point then create speech bubble otherwise not // if (isClickedOnSamePoint == 0) { // console.log('not clicked on same point') // $scope.createSpeechBubbleBasedOnAnnotationLength(pointClicked, x, y, id); // $scope.speechbubbleList.push({ xaxis: x, yaxis: y, ids: id }); // } // $('.appendDragg').draggable({ // drag: function (evt) { // $(this).prev('div').css("display", "none"); // var bor_id = $(this).next('div').attr('id'); // var sub_id1 = $(this).attr('id'); // var verticalScrollPosition = canvasDiv.scrollTop; // var horizontlScrollPosition = canvasDiv.scrollLeft; // if ($scope.speechbubbleList != null || $scope.speechbubbleList != undefined) { // for (var m = 0; m <= $scope.speechbubbleList.length - 1; m++) { // if ($scope.speechbubbleList[m].ids == sub_id1) { // $scope.angle1($scope.speechbubbleList[m].xaxis, $scope.speechbubbleList[m].yaxis, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, bor_id); // break; // } // } // } // }, // }); // $('.dynCross').on('click', function (evt) { // //$(this).parent().parent().parent().css('display', 'none'); // $(this).parent().parent().parent().remove(); // }); //} // else { // $scope.multiAnnotationIsON = false; //history maintained issue //if ($rootScope.isAnnotaionToolBarDrawingModeActive == false) { // $("#sppeachBubble").remove(); // $("#dot").remove(); //} // $(".com").remove(); // $("#bord").remove(); //history maintained issue //if ($rootScope.isAnnotaionToolBarDrawingModeActive == false) { document.getElementById('sppeachBubble').style.zIndex = "60000"; } //$('#sppeachBubble').draggable( //{ // drag: function (evt) { // $("#dot").css("visibility", "hidden"); // var verticalScrollPosition = canvasDiv.scrollTop; // var horizontlScrollPosition = canvasDiv.scrollLeft; // $scope.angle(x, y, evt.pageX + horizontlScrollPosition - $('#imageDiv').offset().left, evt.pageY + verticalScrollPosition - $('#imageDiv').offset().top, true); // }, //}); //$('.crossDiv_temp').on('click', function (evt) { // $('#sppeachBubble').remove(); // $("#bord").remove(); // $("#dot").remove(); //}); //} } $scope.GetAnnotationBasedOnActualTermNo = function (actualTermNo, language) { var Annotation; $scope.ActualTermNo = actualTermNo; for (var j = 0; j <= $rootScope.vocabTermDataArray.length - 1; j++) { if ($rootScope.vocabTermDataArray[j].language == language) { if ($rootScope.vocabTermDataArray[j].VocabTermData != null || $rootScope.vocabTermDataArray[j].VocabTermData != undefined) { $scope.matchedActualTermData = new jinqJs() .from($rootScope.vocabTermDataArray[j].VocabTermData.VocabTerms.Term) .where('_ActualTermNumber == ' + actualTermNo) .select(); if ($scope.matchedActualTermData != null || $scope.matchedActualTermData != undefined) { for (var z = 0; z <= $scope.matchedActualTermData.length; z++) { //send actual term no to get the term text. Annotation = $scope.matchedActualTermData[0]._TermText; // alert("Annotation : " + Annotation); break; }; } return Annotation; } else { return null; } } } } $scope.GetAnnotationText = function (termNumber) { $rootScope.annotationText = []; var annotationText; var annotation = []; //0 var figLeafTermNo = 5868; // to do declare constant for this if (parseInt(termNumber) != parseInt(figLeafTermNo)) { $scope.TermNumber = termNumber; for (var j = 0; j <= $rootScope.lexiconLanguageArray.length - 1; j++) { if ($rootScope.TermNumberData != null || $rootScope.TermNumberData != undefined) { $scope.matchedTermNoData = new jinqJs() .from($rootScope.TermNumberData.TermData.Term) .where('_TermNumber == ' + termNumber) .select(); if ($scope.matchedTermNoData != null || $scope.matchedTermNoData != undefined) { //1. var actualTermNo = 0; for (var z = 0; z < $scope.matchedTermNoData.length; z++) { //send actual term no to get the term text. actualTermNo = $scope.matchedTermNoData[0]._ActualTermNumber; annotationText = $scope.GetAnnotationBasedOnActualTermNo(actualTermNo, $rootScope.lexiconLanguageArray[j].language); annotation.push(annotationText); $rootScope.annotationText.push(annotationText); $rootScope.actualTermNumber = actualTermNo; break; }; //2. } else { // send term no to vocab json data to get the text } } } } return annotation; } $scope.createSpeechBubbleBasedOnAnnotationLength = function (pointClicked, x, y, id) { var sppechBubbleHTML = "
"; //Issue #7286 :Undefined annotation should not appear for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) { var annotation = $scope.MultiLanguageAnnationArray[i]; } if (annotation == undefined) { console.log("No text found"); } else { $("#canvasDiv").append(sppechBubbleHTML); for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) { var annotation = $scope.MultiLanguageAnnationArray[i]; $("#" + id).append("

" + annotation + "

"); } if ($scope.longestAnnotation.length <= 10) { $("#" + id).css("width", "100px"); } else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) { $("#" + id).css("width", "140px"); } else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) { $("#" + id).css("width", "195px"); } else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) { $("#" + id).css("width", "248px"); } else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) { $("#" + id).css("width", "300px"); } else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) { $("#" + id).css("width", "370px"); } else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) { $("#" + id).css("width", "450px"); } else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) { $("#" + id).css("width", "510px"); } else { $("#" + id).css("width", ($scope.longestAnnotation.length) + "%"); } } } $rootScope.Globe1 = []; $scope.createSpeechBubbleBasedOnAnnotationLengthwithoutCtrl = function (x, y, PinId) { var sppechBubbleDotHTML = '' + '
' + '' + '
' + ''; //Issue #7286 :Undefined annotation should not appear 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 { $('#imageDiv').append(sppechBubbleDotHTML); if ($scope.MultiLanguageAnnationArray.length > 0) { for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) { var MultipleLanguage = $scope.MultiLanguageAnnationArray[i]; $("#sppeachBubble"+PinId).append("

" + MultipleLanguage + "

"); } } else { console.log('MultiLanguageAnnationArray.length is :' + $scope.MultiLanguageAnnationArray.length) } if ($scope.longestAnnotation != null || $scope.longestAnnotation != undefined) { if ($scope.longestAnnotation.length <= 10) { $("#sppeachBubble").css("width", "100px"); } else if ($scope.longestAnnotation.length > 10 && $scope.longestAnnotation.length <= 17) { $("#sppeachBubble").css("width", "140px"); } else if ($scope.longestAnnotation.length > 17 && $scope.longestAnnotation.length <= 26) { $("#sppeachBubble").css("width", "195px"); } else if ($scope.longestAnnotation.length > 26 && $scope.longestAnnotation.length <= 34) { $("#sppeachBubble").css("width", "248px"); } else if ($scope.longestAnnotation.length > 34 && $scope.longestAnnotation.length <= 44) { $("#sppeachBubble").css("width", "300px"); } else if ($scope.longestAnnotation.length > 44 && $scope.longestAnnotation.length <= 54) { $("#sppeachBubble").css("width", "370px"); } else if ($scope.longestAnnotation.length > 54 && $scope.longestAnnotation.length <= 69) { $("#sppeachBubble").css("width", "450px"); } else if ($scope.longestAnnotation.length > 69 && $scope.longestAnnotation.length <= 75) { $("#sppeachBubble").css("width", "510px"); } else { $("#sppeachBubble").css("width", ($scope.longestAnnotation.length) + "%"); } } } var Globe = []; debugger; $rootScope.Globe1.push({ "currentX": x, "currentY": y, "id": PinId }); Globe.push({ currentX: x, currentY: y}); document.getElementById('speechBubbleLine' + PinId + '').style.display = 'block'; document.getElementById('speechBubbleLine' + PinId + '').style.left = ((Globe[0].currentX - 45)) + 'px'; document.getElementById('speechBubbleLine' + PinId + '').style.top = ((Globe[0].currentY) - 20) + 'px'; document.getElementById('sppeachBubble' + PinId + '').style.display = 'block'; document.getElementById('sppeachBubble' + PinId + '').style.left = (Globe[0].currentX - 70) + 'px'; document.getElementById('sppeachBubble' + PinId + '').style.top = (Globe[0].currentY - 58) + 'px'; $('.common-drag').draggable( { drag: function (evt) { // $("#dot").css("visibility", "hidden"); var verticalScrollPosition = document.getElementById('imageDiv').scrollTop; var horizontlScrollPosition = document.getElementById('imageDiv').scrollLeft; var a = $(this).attr("id"); var res = a.substring(13, a.length); $("#speechBubbleLine" + res).css("visibility", "hidden"); // var c = ($("#sppeachBubble" + res).css("left")).toString().replace("px", ""); // alert(c); //var d = ($("#sppeachBubble" + res).css("top")).toString().replace("px", ""); // alert(d); console.log("res= " + res + "x= " + x + ",y= " + y + ",evt.pageY= " + evt.page + ",evt.pageX= " + evt.pageX + ",horizontlScrollPosition= " + horizontlScrollPosition + ",verticalScrollPosition= " + verticalScrollPosition); // alert(evt.pageX + "X" + evt.pageY + "horizontlScrollPosition" + horizontlScrollPosition + "verticalScrollPosition" + verticalScrollPosition); for (var i = 0; i <= $rootScope.Globe1.length - 1; i++) { if ($rootScope.Globe1[i].id == res) { // alert($rootScope.Globe1[i].currentX); $scope.angle(res, $rootScope.Globe1[i].currentX, $rootScope.Globe1[i].currentY, evt.pageX + horizontlScrollPosition - $('#imageDiv').offset().left, evt.pageY + verticalScrollPosition - $('#imageDiv').offset().top, true); } } }, }); $('.crossDiv_temp').on('click', function (evt) { var imgId = $(this).attr("id"); var pinId = imgId.substring(8, imgId.length); $('#sppeachBubble' + pinId).remove(); $("#speechBubbleDraggedLine" + pinId).remove(); $("#speechBubbleLine" + pinId).remove(); }); } $scope.angle = function (id, cx, cy, ex, ey, BoolValues) { // debugger; // alert(ex + " " + ey); 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; // alert(d); if (BoolValues == true) { $("#speechBubbleDraggedLine"+id).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%' }); } 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%' }); } } }]); function showSelectedSystemPins(event) { console.log('OnBodySystem chnaged is called outside '); var scope = angular.element(document.getElementById("aaDetailPageDiv")).scope(); scope.$apply(function () { scope.showSelectedSystemPins(event); }); }