");
}
$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
}
//1. create a jsPanel and load the module item view
if ($rootScope.moduleName == ATLAS_ANATOMY) {
$.jsPanel({
id: 'ImagePanel',
selector: '.aaBodyView',
theme: 'success',
currentController: 'TileViewListController',
parentSlug: 'tile-view-list',
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.id = 'modItemImage';
openedImage.name = $rootScope.OpenItemImagePath;
openedImage.onload = function () {
$scope.imageWidth = this.width;
$scope.imageHeight = this.height;
$timeout(function () {
$compile(aaViewElement.contents())($scope);
if (document.getElementById('aaDetailPageDiv') != null) {
//0.4 added some stylesheets
$rootScope.canvasDivHeight = $('.jsPanel-content').height() - $('.main2 .stickey-area').height();
$('.canvasDivClass').css("height", $rootScope.canvasDivHeight);
$scope.currentTitleFromJson = localStorage.getItem("currentViewTitle");
$("#modItemImage").attr('src', $rootScope.OpenItemImagePath);
$rootScope.ViewImageWidth = $("#modItemImage").width();
$scope.ViewImageWidth = $("#modItemImage").width();
$scope.ViewImageHeight = $("#modItemImage").height();
$scope.relativeDimesion = 0;
$("#modItemImage").css("width", $rootScope.ViewImageWidth + "px");
//0.5 create canvas on the top of image so that I can draw a line over the canvas.
var canvas = document.createElement('canvas');
canvas.id = 'aaDetailViewCanvas';
canvas.className = '.aaCanvas'
canvas.height = parseInt(($scope.imageHeight));
canvas.width = parseInt($scope.imageWidth);
canvas.style.left = '0px';
canvas.style.top = '0px';
canvas.style.position = "absolute";
$("#canvasDiv").append(canvas);
$scope.context = canvas.getContext("2d")
//6. Show all pins on AA opened item
$scope.showAllPins();
//7. Highlight all system body list in left side
$scope.highlightBodySystemList();
}
}, 1050);
}
openedImage.onerror = loadFailure;
openedImage.src = $rootScope.OpenItemImagePath;
}
}
$scope.highlightBodySystemList = function () {
$rootScope.bodySystemNames = $rootScope.bodySystemName.trim().split(/\s*,\s*/);
var bodySystemListObj = document.getElementById("bodySystemList").getElementsByTagName("a");
var bodySystemListlength = bodySystemListObj.length;
for (var i = 0; i < bodySystemListlength; i++) {
//var boldTag = lis[i];
for (var j = 0; j < $rootScope.bodySystemNames.length; j++) {
if ((bodySystemListObj[i].innerHTML) == ($rootScope.bodySystemNames[j])) {
$("#" + i).parent().removeClass("disabled");
}
}
}
}
function loadFailure() {
console.log('unable to load opened module ietem');
return true;
}
angular.element(document).ready(function (e) {
$("#ImagePanel").resize(function () {
$("#canvasDiv").scrollLeft($rootScope.CanvasDivLeftPosition);
$("#canvasDiv").scrollTop($rootScope.CanvasDivTopPosition);
});
$(document).on("click", "#ImagePanel .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-close .jsglyph-remove", function () {
$scope.setActiveTab(parseInt(localStorage.getItem("activeTab")));
$(".tools").css("z-index", "15000");
$rootScope.selectedBodySystemName = 'All';
$rootScope.selectedBodySystemId = 0;
$rootScope.searchSelectedText = '';
});
})
$scope.showAllPins = function () {
$scope.allPinDataArray = [];
var promise = ModuleService.getPinDataForImage($rootScope.imageName)
.then(
function (result) {
//load navigator image
if (result.data.Root._NavigatorImage != undefined) {
document.getElementById('navimg').src = '~/../content/images/aa/images/navigator/' + result.data.Root._NavigatorImage;
}
else {
document.getElementById('navimg').style.visibility = 'hidden';
document.getElementById('navigatorBtn').style.visibility = 'hidden';
document.getElementById('navigatorDiv').style.visibility = 'hidden';
}
//draw pins
$scope.aaPinData = result.data.Root.Item;
if ($scope.aaPinData != null && $scope.aaPinData.length > 0) {
angular.forEach($scope.aaPinData, function (value, key) {
$scope.allPinDataArray.push(value._PinId);
$scope.drawStaticPinsOnImage('aaDetailViewCanvas', value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY)
})
//load search/vocab data
$rootScope.loadSearchData();
}
},
function (error) {
console.log(' error in showAllPins: ' + error.statusText);
}
)
if ($scope.isSliderChange == true) {
$timeout(function () {
$scope.activePinOnLayerChange();
}, 1000);
}
}
$scope.FilterByImage = function (moduleId, 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) {
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
$scope.removeSpeechBubble();
if (event.currentTarget.id == "0") {
$scope.selectedSystemName = null;
if ($scope.isHidePinBtnClicked) {
// $scope.showAllPinsAfterHide($scope.aaPinData);
$scope.showAllPinsAfterHide();
}
else {
$scope.showAllPins();
}
}
else {
$scope.selectedSystemName = event.currentTarget.title;
// get termText info
var promise = ModuleService.getTermTextDataForPin($scope.moduleName)
.then(
function (response) {
$scope.TermInfo = response.data.Terms.Term;
//on gettng all required data, draw pins
if ($scope.aaPinData != null && $scope.aaPinData.length > 0) {
$scope.selectedSystemPinData = new jinqJs()
.from($scope.aaPinData)
.where("_BodySystemName == " + $scope.selectedSystemName)
.select();
if ($scope.isHidePinBtnClicked) {
// $scope.showAllPinsAfterHide($scope.selectedSystemPinData);
$scope.showAllPinsAfterHide();
}
else {
//remove other system pins
if ($scope.selectedSystemPinData != null && $scope.selectedSystemPinData.length > 0) {
angular.forEach($scope.aaPinData, function (aaPinDataValue, aaPinDataKey) {
if (aaPinDataValue._BodySystemName != $scope.selectedSystemName)
$scope.removePin('aaDetailViewCanvas', aaPinDataValue._PinId);
})
angular.forEach($scope.selectedSystemPinData, function (value, key) {
$scope.drawStaticPinsOnImage('aaDetailViewCanvas', value._PinId, value._PinX, value._PinY, value._HeadX, value._HeadY)
})
//show annotation on first pin of the sysyem
$scope.showAnnotation($scope.selectedSystemPinData, false, false, false);
}
}
}
},
function (error) {
// handle errors here
console.log(' error: ' + error.statusText);
}
)
}
}
$scope.showAnnotation = function (selectedPinData, isCtrlPressed, isPinClicked, isItemSearched) {
$scope.selectedPin = [];
var isSameTermWithMultiPin = false;
var firstPinId = selectedPinData[0]._PinId;
var pinTermNumber = selectedPinData[0]._TermId;
//check if other pin have same termNumber
if ($scope.aaPinData != null && $scope.aaPinData.length > 0) {
var pinDataWithFirstTermNumber = new jinqJs()
.from($scope.aaPinData)
.where("_TermId == " + pinTermNumber)
.select();
$scope.MultiLanguageAnnationArray = [];
$scope.GetAnnotationBasedOnActualTermNo(pinTermNumber);
if (isCtrlPressed) {
}
else {
if (isPinClicked || isItemSearched) {
var existingSpeechBubble = $("div[id*='speechBubble']");
for (var i = 0; i < existingSpeechBubble.length; i++) {
existingSpeechBubble[i].parentNode.removeChild(existingSpeechBubble[i]);
//make all pin heads grey
var radial = $('#aaDetailViewCanvas').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').setLayers({
fillStyle: radial,
}).drawLayers();
}
var existingSpeechBubbleLine = $("div[id*='speechBubbleLine']");
for (var i = 0; i < existingSpeechBubbleLine.length; i++) {
existingSpeechBubbleLine[i].parentNode.removeChild(existingSpeechBubbleLine[i]);
}
var speechBubbleDraggedLine = $("div[id*='speechBubbleDraggedLine']");
for (var i = 0; i < speechBubbleDraggedLine.length; i++) {
speechBubbleDraggedLine[i].parentNode.removeChild(speechBubbleDraggedLine[i]);
}
}
}
if (pinDataWithFirstTermNumber.length > 1) {
isSameTermWithMultiPin = true;
}
angular.forEach(pinDataWithFirstTermNumber, function (value, key) {
$scope.selectedPin.push(value._PinId);
var headX = (parseInt(value._HeadX));
var headY = (parseInt(value._HeadY));
$scope.createSpeechBubble(parseInt(headX) + 10, parseInt(headY) + 10, value._PinId, isCtrlPressed, isPinClicked, isSameTermWithMultiPin);
})
}
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
// $scope.MultiLanguageAnnationArray.push($rootScope.annotationText[i])
}
$scope.removeSpeechBubble = function () {
//clear speech bubbles
var speechBubbles = $("div[id*='speechBubble']");
if (speechBubbles != null || speechBubbles != undefined && speechBubbles.length > 0) {
for (var j = 0; j < speechBubbles.length; j++) {
speechBubbles[j].parentNode.removeChild(speechBubbles[j]);
}
}
var speechBubbleLines = $("div[id*='speechBubbleLine']");
if (speechBubbleLines != null || speechBubbleLines != undefined && speechBubbleLines.length > 0) {
for (var j = 0; j < speechBubbleLines.length; j++) {
speechBubbleLines[j].parentNode.removeChild(speechBubbleLines[j]);
}
}
var speechBubbleDraggedLines = $("div[id*='speechBubbleDraggedLine']");
if (speechBubbleDraggedLines != null || speechBubbleDraggedLines != undefined && speechBubbleDraggedLines.length > 0) {
for (var j = 0; j < speechBubbleDraggedLines.length; j++) {
speechBubbleDraggedLines[j].parentNode.removeChild(speechBubbleDraggedLines[j]);
}
}
};
$scope.showSpeechBubble = function () {
//clear speech bubbles
var speechBubbles = $("div[id*='speechBubble']");
if (speechBubbles != null || speechBubbles != undefined && speechBubbles.length > 0) {
for (var j = 0; j < speechBubbles.length; j++) {
document.getElementById(speechBubbles[j].id).style.visibility = 'visible';
}
}
var speechBubbleLines = $("div[id*='speechBubbleLine']");
if (speechBubbleLines != null || speechBubbleLines != undefined && speechBubbleLines.length > 0) {
for (var j = 0; j < speechBubbleLines.length; j++) {
document.getElementById(speechBubbleLines[j].id).style.visibility = 'visible';
}
}
var speechBubbleDraggedLines = $("div[id*='speechBubbleDraggedLine']");
if (speechBubbleDraggedLines != null || speechBubbleDraggedLines != undefined && speechBubbleDraggedLines.length > 0) {
for (var j = 0; j < speechBubbleDraggedLines.length; j++) {
document.getElementById(speechBubbleDraggedLines[j].id).style.visibility = 'visible';
}
}
};
$scope.hideSpeechBubble = function () {
//clear speech bubbles
var speechBubbles = $("div[id*='speechBubble']");
if (speechBubbles != null || speechBubbles != undefined && speechBubbles.length > 0) {
for (var j = 0; j < speechBubbles.length; j++) {
document.getElementById(speechBubbles[j].id).style.visibility = 'hidden';
}
}
var speechBubbleLines = $("div[id*='speechBubbleLine']");
if (speechBubbleLines != null || speechBubbleLines != undefined && speechBubbleLines.length > 0) {
for (var j = 0; j < speechBubbleLines.length; j++) {
document.getElementById(speechBubbleLines[j].id).style.visibility = 'hidden';
}
}
var speechBubbleDraggedLines = $("div[id*='speechBubbleDraggedLine']");
if (speechBubbleDraggedLines != null || speechBubbleDraggedLines != undefined && speechBubbleDraggedLines.length > 0) {
for (var j = 0; j < speechBubbleDraggedLines.length; j++) {
document.getElementById(speechBubbleDraggedLines[j].id).style.visibility = 'hidden';
}
}
};
$scope.createSpeechBubble = function (x, y, PinId, isCtrlPressed, isPinClicked, isSameTermWithMultiPin) {
$scope.longestAnnotation = $scope.MultiLanguageAnnationArray.reduce(function (firstAnnotation, seconAnnotation) { return firstAnnotation.length > seconAnnotation.length ? firstAnnotation : seconAnnotation; });
$scope.createSpeechBubbleBasedOnAnnotationLength(x, y, PinId);
$('#speechBubble').draggable(
{
drag: function (evt) {
$("#dot").css("visibility", "hidden");
var verticalScrollPosition = canvasDiv.scrollTop;
var horizontlScrollPosition = canvasDiv.scrollLeft;
$scope.angle(x * $scope.sliderPercentValue, y * $scope.sliderPercentValue, evt.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left, evt.pageY + verticalScrollPosition - $('#canvasDiv').offset().top, true);
},
});
}
$scope.sliderVal = 100;
$scope.createSpeechBubbleBasedOnAnnotationLength = function (x, y, PinId) {
x = x * $scope.sliderPercentValue;
y = y * $scope.sliderPercentValue;
var speechBubbleHTML = ''
+ '
'
+ ''
+ '
'
+ '
'
+ '
';
//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 {
$('#canvasDiv').append(speechBubbleHTML);
if ($scope.MultiLanguageAnnationArray.length > 0) {
for (var i = 0; i <= $scope.MultiLanguageAnnationArray.length - 1; i++) {
var MultipleLanguage = $scope.MultiLanguageAnnationArray[i];
$("#speechBubble" + PinId).append("