Commit 6782af94170dbed31f0513622a29647dc7f9f22d
1 parent
86d38287
added null checks.
rename a varibale. fixed issue after renaming.
Showing
1 changed file
with
109 additions
and
176 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/TileViewListController.js
... | ... | @@ -22,7 +22,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
22 | 22 | $scope.AllBodySystem = []; |
23 | 23 | $scope.AllOrientation = []; |
24 | 24 | $scope.AllImageType = []; |
25 | - $rootScope.Globe1 = []; | |
25 | + $rootScope.speechBubbleDimaensions = []; | |
26 | 26 | |
27 | 27 | $scope.query = { |
28 | 28 | selectedbodyregion: '', |
... | ... | @@ -189,11 +189,13 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
189 | 189 | .then( |
190 | 190 | function (result) { |
191 | 191 | $scope.aaPinData = result.data.Root.Item; |
192 | - angular.forEach($scope.aaPinData, function (value, key) { | |
192 | + if ($scope.aaPinData != null && $scope.aaPinData.length > 0) { | |
193 | 193 | |
194 | - $scope.drawStaticPinsOnImage('aaDetailViewCanvas', value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY) | |
195 | - }) | |
194 | + angular.forEach($scope.aaPinData, function (value, key) { | |
196 | 195 | |
196 | + $scope.drawStaticPinsOnImage('aaDetailViewCanvas', value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY) | |
197 | + }) | |
198 | + } | |
197 | 199 | }, |
198 | 200 | function (error) { |
199 | 201 | |
... | ... | @@ -404,10 +406,10 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
404 | 406 | |
405 | 407 | $scope.showSelectedSystemPins = function (event) { |
406 | 408 | |
407 | - | |
409 | + $scope.removeSpeechBubble(); | |
408 | 410 | if (event.currentTarget.id == "0") { |
409 | 411 | |
410 | - $scope.removeSpeechBubble(); | |
412 | + | |
411 | 413 | $scope.showAllPins(); |
412 | 414 | |
413 | 415 | } |
... | ... | @@ -424,25 +426,31 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
424 | 426 | $scope.TermInfo = response.data.Terms.Term; |
425 | 427 | |
426 | 428 | //on gettng all required data, draw pins |
427 | - var selectedSystemPinData = new jinqJs() | |
428 | - .from($scope.aaPinData) | |
429 | - .where("_BodySystemName == " + selectedSystemName) | |
430 | - .select(); | |
431 | - //remove other system pins | |
432 | - angular.forEach($scope.aaPinData, function (aaPinDataValue, aaPinDataKey) { | |
433 | - // angular.forEach(selectedSystemPinData, function (selectedSystemPinDataValue, selectedSystemPinDataKey) { | |
434 | - if (aaPinDataValue._BodySystemName != selectedSystemName) | |
435 | - $scope.removePin('aaDetailViewCanvas', aaPinDataValue._PinId); | |
436 | - }) | |
429 | + if ($scope.aaPinData != null && $scope.aaPinData.length > 0) { | |
430 | + | |
431 | + var selectedSystemPinData = new jinqJs() | |
432 | + .from($scope.aaPinData) | |
433 | + .where("_BodySystemName == " + selectedSystemName) | |
434 | + .select(); | |
435 | + //remove other system pins | |
436 | + if (selectedSystemPinData != null && selectedSystemPinData.length > 0) { | |
437 | + | |
438 | + angular.forEach($scope.aaPinData, function (aaPinDataValue, aaPinDataKey) { | |
437 | 439 | |
438 | - angular.forEach(selectedSystemPinData, function (value, key) { | |
440 | + if (aaPinDataValue._BodySystemName != selectedSystemName) | |
441 | + $scope.removePin('aaDetailViewCanvas', aaPinDataValue._PinId); | |
442 | + }) | |
439 | 443 | |
444 | + angular.forEach(selectedSystemPinData, function (value, key) { | |
440 | 445 | |
441 | - $scope.drawStaticPinsOnImage('aaDetailViewCanvas', value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY) | |
442 | 446 | |
443 | - }) | |
444 | - //show annotation on first pin of the sysyem | |
445 | - $scope.showAnnotation(selectedSystemPinData, false, false); | |
447 | + $scope.drawStaticPinsOnImage('aaDetailViewCanvas', value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY) | |
448 | + | |
449 | + }) | |
450 | + //show annotation on first pin of the sysyem | |
451 | + $scope.showAnnotation(selectedSystemPinData, false, false); | |
452 | + } | |
453 | + } | |
446 | 454 | }, |
447 | 455 | function (error) { |
448 | 456 | // handle errors here |
... | ... | @@ -461,77 +469,82 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
461 | 469 | var pinTermNumber = selectedSystemPinData[0]._TermId; |
462 | 470 | |
463 | 471 | //check if other pin have same termNumber |
464 | - var pinDataWithFirstTermNumber = new jinqJs() | |
465 | - .from($scope.aaPinData) | |
466 | - .where("_TermId == " + pinTermNumber) | |
467 | - .select(); | |
472 | + if ($scope.aaPinData != null && $scope.aaPinData.length > 0) { | |
468 | 473 | |
474 | + var pinDataWithFirstTermNumber = new jinqJs() | |
475 | + .from($scope.aaPinData) | |
476 | + .where("_TermId == " + pinTermNumber) | |
477 | + .select(); | |
469 | 478 | |
470 | 479 | |
471 | - // get termText info | |
472 | - var promise = ModuleService.getTermTextDataForPin($scope.moduleName) | |
473 | - .then( | |
474 | - function (response) { | |
475 | 480 | |
476 | - $scope.TermInfo = response.data.Terms.Term; | |
481 | + // get termText info | |
482 | + var promise = ModuleService.getTermTextDataForPin($scope.moduleName) | |
483 | + .then( | |
484 | + function (response) { | |
477 | 485 | |
486 | + $scope.TermInfo = response.data.Terms.Term; | |
478 | 487 | |
479 | - var termTextdata = new jinqJs() | |
480 | - .from($scope.TermInfo) | |
481 | - .where("__ActualTermNumber == " + pinTermNumber) | |
482 | - .select(); | |
488 | + if ($scope.TermInfo != null && $scope.TermInfo.length > 0) { | |
483 | 489 | |
484 | - var termText = termTextdata[0].__TermText; | |
485 | - $scope.MultiLanguageAnnationArray = []; | |
486 | - $scope.MultiLanguageAnnationArray.push(termText); | |
490 | + var termTextdata = new jinqJs() | |
491 | + .from($scope.TermInfo) | |
492 | + .where("__ActualTermNumber == " + pinTermNumber) | |
493 | + .select(); | |
487 | 494 | |
488 | - if (isCtrlPressed) { | |
495 | + var termText = termTextdata[0].__TermText; | |
496 | + $scope.MultiLanguageAnnationArray = []; | |
497 | + $scope.MultiLanguageAnnationArray.push(termText); | |
489 | 498 | |
490 | - } | |
491 | - else { | |
492 | - if (isPinClicked) { | |
493 | - var existingSpeechBubble = $("div[id*='speechBubble']"); | |
494 | - for (var i = 0; i < existingSpeechBubble.length; i++) { | |
495 | - existingSpeechBubble[i].parentNode.removeChild(existingSpeechBubble[i]); | |
496 | - | |
497 | - //make all pin heads grey | |
498 | - var radial = $('#aaDetailViewCanvas').createGradient({ | |
499 | - x1: 50, y1: 50, | |
500 | - x2: 50, y2: 50, | |
501 | - r1: 10, r2: 30, | |
502 | - c1: 'rgba(100, 50, 0,0)', | |
503 | - c2: 'rgb(216, 216, 216)' | |
504 | - }); | |
505 | - | |
506 | - | |
507 | - $('#aaDetailViewCanvas').setLayers({ | |
508 | - fillStyle: radial, | |
509 | - }).drawLayers(); | |
510 | - } | |
499 | + if (isCtrlPressed) { | |
511 | 500 | |
512 | - var existingSpeechBubbleLine = $("div[id*='speechBubbleLine']"); | |
513 | - for (var i = 0; i < existingSpeechBubbleLine.length; i++) { | |
514 | - existingSpeechBubbleLine[i].parentNode.removeChild(existingSpeechBubbleLine[i]); | |
515 | 501 | } |
516 | - var speechBubbleDraggedLine = $("div[id*='speechBubbleDraggedLine']"); | |
517 | - for (var i = 0; i < speechBubbleDraggedLine.length; i++) { | |
518 | - speechBubbleDraggedLine[i].parentNode.removeChild(speechBubbleDraggedLine[i]); | |
502 | + else { | |
503 | + if (isPinClicked) { | |
504 | + var existingSpeechBubble = $("div[id*='speechBubble']"); | |
505 | + for (var i = 0; i < existingSpeechBubble.length; i++) { | |
506 | + existingSpeechBubble[i].parentNode.removeChild(existingSpeechBubble[i]); | |
507 | + | |
508 | + //make all pin heads grey | |
509 | + var radial = $('#aaDetailViewCanvas').createGradient({ | |
510 | + x1: 50, y1: 50, | |
511 | + x2: 50, y2: 50, | |
512 | + r1: 10, r2: 30, | |
513 | + c1: 'rgba(100, 50, 0,0)', | |
514 | + c2: 'rgb(216, 216, 216)' | |
515 | + }); | |
516 | + | |
517 | + | |
518 | + $('#aaDetailViewCanvas').setLayers({ | |
519 | + fillStyle: radial, | |
520 | + }).drawLayers(); | |
521 | + } | |
522 | + | |
523 | + var existingSpeechBubbleLine = $("div[id*='speechBubbleLine']"); | |
524 | + for (var i = 0; i < existingSpeechBubbleLine.length; i++) { | |
525 | + existingSpeechBubbleLine[i].parentNode.removeChild(existingSpeechBubbleLine[i]); | |
526 | + } | |
527 | + var speechBubbleDraggedLine = $("div[id*='speechBubbleDraggedLine']"); | |
528 | + for (var i = 0; i < speechBubbleDraggedLine.length; i++) { | |
529 | + speechBubbleDraggedLine[i].parentNode.removeChild(speechBubbleDraggedLine[i]); | |
530 | + } | |
531 | + } | |
532 | + } | |
533 | + if (pinDataWithFirstTermNumber.length > 1) { | |
534 | + isSameTermWithMultiPin = true; | |
519 | 535 | } |
520 | - } | |
521 | - } | |
522 | - if (pinDataWithFirstTermNumber.length > 1) { | |
523 | - isSameTermWithMultiPin = true; | |
524 | - } | |
525 | 536 | |
526 | - angular.forEach(pinDataWithFirstTermNumber, function (value, key) { | |
527 | - $scope.selectedPin.push(value._PinId); | |
528 | - var headX = (parseInt(value._HeadX)); | |
529 | - var headY = (parseInt(value._HeadY)); | |
530 | - $scope.createSpeechBubble(parseInt(headX) + 10, parseInt(headY) + 10, value._PinId, isCtrlPressed, isPinClicked, isSameTermWithMultiPin); | |
531 | - }) | |
537 | + angular.forEach(pinDataWithFirstTermNumber, function (value, key) { | |
538 | + $scope.selectedPin.push(value._PinId); | |
539 | + var headX = (parseInt(value._HeadX)); | |
540 | + var headY = (parseInt(value._HeadY)); | |
541 | + $scope.createSpeechBubble(parseInt(headX) + 10, parseInt(headY) + 10, value._PinId, isCtrlPressed, isPinClicked, isSameTermWithMultiPin); | |
542 | + }) | |
543 | + } | |
544 | + }, | |
532 | 545 | |
533 | - }, | |
534 | - function (error) { }) | |
546 | + function (error) { }) | |
547 | + } | |
535 | 548 | } |
536 | 549 | |
537 | 550 | $scope.removeSpeechBubble = function () { |
... | ... | @@ -582,84 +595,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
582 | 595 | |
583 | 596 | } |
584 | 597 | |
585 | - $scope.getAnnotationBasedOnActualTermNo = function (actualTermNo, language) { | |
586 | - | |
587 | - var Annotation; | |
588 | - $scope.ActualTermNo = actualTermNo; | |
589 | - for (var j = 0; j <= $rootScope.vocabTermDataArray.length - 1; j++) { | |
590 | - | |
591 | - if ($rootScope.vocabTermDataArray[j].language == language) { | |
592 | - | |
593 | - if ($rootScope.vocabTermDataArray[j].VocabTermData != null || $rootScope.vocabTermDataArray[j].VocabTermData != undefined) { | |
594 | - $scope.matchedActualTermData = new jinqJs() | |
595 | - .from($rootScope.vocabTermDataArray[j].VocabTermData.VocabTerms.Term) | |
596 | - .where('_ActualTermNumber == ' + actualTermNo) | |
597 | - .select(); | |
598 | - | |
599 | - if ($scope.matchedActualTermData != null || $scope.matchedActualTermData != undefined) { | |
600 | - for (var z = 0; z <= $scope.matchedActualTermData.length; z++) { | |
601 | - //send actual term no to get the term text. | |
602 | - Annotation = $scope.matchedActualTermData[0]._TermText; | |
603 | - // alert("Annotation : " + Annotation); | |
604 | - break; | |
605 | - }; | |
606 | - } | |
607 | - return Annotation; | |
608 | - } | |
609 | - | |
610 | - else { | |
611 | - return null; | |
612 | - } | |
613 | - | |
614 | - } | |
615 | - } | |
616 | - | |
617 | - } | |
618 | - | |
619 | - //$scope.getAnnotationText = function (termNumber) { | |
620 | - // $rootScope.annotationText = []; | |
621 | - // var annotationText; | |
622 | - // var annotation = []; | |
623 | - // //0 | |
624 | - // var figLeafTermNo = 5868; // to do declare constant for this | |
625 | - | |
626 | - // if (parseInt(termNumber) != parseInt(figLeafTermNo)) { | |
627 | - // $scope.TermNumber = termNumber; | |
628 | - // for (var j = 0; j <= $rootScope.lexiconLanguageArray.length - 1; j++) { | |
629 | - // if ($rootScope.TermNumberData != null || $rootScope.TermNumberData != undefined) { | |
630 | - // $scope.matchedTermNoData = new jinqJs() | |
631 | - // .from($rootScope.TermNumberData.TermData.Term) | |
632 | - // .where('_TermNumber == ' + termNumber) | |
633 | - // .select(); | |
634 | - | |
635 | - // if ($scope.matchedTermNoData != null || $scope.matchedTermNoData != undefined) { | |
636 | - // //1. | |
637 | - // var actualTermNo = 0; | |
638 | - // for (var z = 0; z < $scope.matchedTermNoData.length; z++) { | |
639 | - // //send actual term no to get the term text. | |
640 | - // actualTermNo = $scope.matchedTermNoData[0]._ActualTermNumber; | |
641 | - // annotationText = $scope.getAnnotationBasedOnActualTermNo(actualTermNo, $rootScope.lexiconLanguageArray[j].language); | |
642 | - // annotation.push(annotationText); | |
643 | - // $rootScope.annotationText.push(annotationText); | |
644 | - // $rootScope.actualTermNumber = actualTermNo; | |
645 | - // break; | |
646 | - // }; | |
647 | - | |
648 | - // //2. | |
649 | - | |
650 | - // } | |
651 | - // else { | |
652 | - // // send term no to vocab json data to get the text | |
653 | - // } | |
654 | - // } | |
655 | - // } | |
656 | - // } | |
657 | - | |
658 | - // return annotation; | |
659 | - //} | |
660 | - | |
661 | - | |
662 | - | |
663 | 598 | $scope.createSpeechBubbleBasedOnAnnotationLength = function (x, y, PinId) { |
664 | 599 | |
665 | 600 | var speechBubbleHTML = '<div id="speechBubbleLine' + PinId + '" style="position:absolute;height:15px;width:35px;display:none;z-index:10000;border-top:2px solid #000;transform:rotate(40deg);-moz-transform:rotate(40deg);-o-transform:rotate(40deg);-ms-transform:rotate(40deg);-webkit-transform:rotate(40deg);"></div>' |
... | ... | @@ -737,43 +672,41 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
737 | 672 | } |
738 | 673 | } |
739 | 674 | } |
740 | - var Globe = []; | |
675 | + var speechBubbleDims = []; | |
741 | 676 | |
742 | - $rootScope.Globe1.push({ "currentX": x, "currentY": y, "id": PinId }); | |
743 | - Globe.push({ currentX: x, currentY: y }); | |
677 | + $rootScope.speechBubbleDimaensions.push({ "currentX": x, "currentY": y, "id": PinId }); | |
678 | + speechBubbleDims.push({ currentX: x, currentY: y }); | |
744 | 679 | document.getElementById('speechBubbleLine' + PinId + '').style.display = 'block'; |
745 | - document.getElementById('speechBubbleLine' + PinId + '').style.left = ((Globe[0].currentX - 45)) + 'px'; | |
746 | - document.getElementById('speechBubbleLine' + PinId + '').style.top = ((Globe[0].currentY) - 20) + 'px'; | |
680 | + document.getElementById('speechBubbleLine' + PinId + '').style.left = ((speechBubbleDims[0].currentX - 45)) + 'px'; | |
681 | + document.getElementById('speechBubbleLine' + PinId + '').style.top = ((speechBubbleDims[0].currentY) - 20) + 'px'; | |
747 | 682 | document.getElementById('speechBubble' + PinId + '').style.display = 'block'; |
748 | - document.getElementById('speechBubble' + PinId + '').style.left = (Globe[0].currentX - 70) + 'px'; | |
749 | - document.getElementById('speechBubble' + PinId + '').style.top = (Globe[0].currentY - 58) + 'px'; | |
683 | + document.getElementById('speechBubble' + PinId + '').style.left = (speechBubbleDims[0].currentX - 70) + 'px'; | |
684 | + document.getElementById('speechBubble' + PinId + '').style.top = (speechBubbleDims[0].currentY - 58) + 'px'; | |
750 | 685 | |
751 | 686 | $('.common-drag').draggable( |
752 | 687 | { |
688 | + | |
753 | 689 | drag: function (evt) { |
754 | - | |
690 | + //debugger; | |
755 | 691 | var verticalScrollPosition = document.getElementById('imageDiv').scrollTop; |
756 | 692 | var horizontlScrollPosition = document.getElementById('imageDiv').scrollLeft; |
757 | - var a = $(this).attr("id"); | |
693 | + var clickedSpeechBubbleId = $(this).attr("id"); | |
758 | 694 | |
759 | - var res = a.substring(13, a.length); | |
760 | - $("#speechBubbleLine" + res).css("visibility", "hidden"); | |
695 | + var clickedPinId = clickedSpeechBubbleId.substring(12, a.length); | |
761 | 696 | |
762 | - | |
763 | - console.log("res= " + res + "x= " + x + ",y= " + y + ",evt.pageY= " + evt.page + ",evt.pageX= " + evt.pageX + ",horizontlScrollPosition= " + horizontlScrollPosition + ",verticalScrollPosition= " + verticalScrollPosition); | |
697 | + $("#speechBubbleLine" + clickedPinId).css("visibility", "hidden"); | |
764 | 698 | |
765 | - | |
766 | - for (var i = 0; i <= $rootScope.Globe1.length - 1; i++) { | |
767 | - if ($rootScope.Globe1[i].id == res) { | |
768 | - | |
769 | - $scope.angle(res, $rootScope.Globe1[i].currentX, $rootScope.Globe1[i].currentY, evt.pageX + horizontlScrollPosition - $('#imageDiv').offset().left, evt.pageY + verticalScrollPosition - $('#imageDiv').offset().top, true); | |
699 | + | |
700 | + for (var i = 0; i <= $rootScope.speechBubbleDimaensions.length - 1; i++) { | |
701 | + if ($rootScope.speechBubbleDimaensions[i].id == clickedPinId) { | |
702 | + $scope.angle(clickedPinId, $rootScope.speechBubbleDimaensions[i].currentX, $rootScope.speechBubbleDimaensions[i].currentY, evt.pageX + horizontlScrollPosition - $('#imageDiv').offset().left, evt.pageY + verticalScrollPosition - $('#imageDiv').offset().top, true); | |
770 | 703 | } |
771 | 704 | } |
772 | 705 | |
773 | 706 | }, |
774 | 707 | }); |
775 | 708 | $('.crossDiv_temp').on('click', function (evt) { |
776 | - | |
709 | + | |
777 | 710 | var imgId = $(this).attr("id"); |
778 | 711 | var pinId = imgId.substring(8, imgId.length); |
779 | 712 | $('#speechBubble' + pinId).remove(); |
... | ... | @@ -795,7 +728,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo |
795 | 728 | fillStyle: radial, |
796 | 729 | }).drawLayers(); |
797 | 730 | }); |
798 | - | |
731 | + | |
799 | 732 | //make the head green |
800 | 733 | var radialAfterClick = $('#aaDetailViewCanvas').createGradient({ |
801 | 734 | x1: 50, y1: 50, | ... | ... |