AIA.controller("CIController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "MedicalSpecialties", "DataService", "ModuleService", "$interval",
function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, BodyRegions, BodySystems, ViewOrientations, ImageTypes, MedicalSpecialties, DataService, ModuleService, $interval) {
$scope.CIAllBodyRegion = [];
$scope.CIAllBodySystem = [];
$scope.CIAllOrientation = [];
$scope.CIAllImageType = [];
$scope.CIAllSpeciality = [];
$scope.selectedCIListViewData = [];
//$scope.searchCIListViewData = [];
$scope.SelectedCIthumbImage = [];
$scope.SelectedCISummary = [];
$scope.SelectedCIId = [];
$scope.SelectedCITitle = [];
$scope.filterstring = false;
$scope.idSelected;
$scope.srollListView;
$scope.showTabButton = true;
$scope.query = {
selectedbodyregion: '',
selectedbodysystem: '',
selectedorientation: '',
selectedimagetype: '',
selectedspecialty: '',
};
//************************************
$scope.setActiveTab = function (tabToSet) {
$scope.activeTab = tabToSet;
localStorage.setItem("currentCITabView", $scope.activeTab);
};
$scope.initializeCIWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) {
if (isOpenWithExistsModule || openPanelNo == 0) {
if ($rootScope.CIWindowData != undefined) {
$rootScope.CIWindowData.length = 0;
}
else {
$rootScope.CIWindowData = [];
}
$rootScope.CIWindowData.push(
{
'multiwinid': windowviewid,
'IllustrationData': [],
'searchCIListViewData': [],
'CIImagePath': '',
'ImageSummary': '',
'moduleName': '',
'currentViewTitle': '',
'parentSlugName': '',
'currentSlug': '',
'imageId': '',
'imageName': '',
'isTextVisible': true,
'top': 0,
'left': 0,
'width': 0,
'height': 0,
'minimised': false,
'maximised': false
});
}
else {
var isNewWindow = true;
for (var k = 0; k < $rootScope.CIWindowData.length; k++) {
if ($rootScope.CIWindowData[k].multiwinid == windowviewid) {
isNewWindow = false;
break;
}
}
if (isNewWindow) {
$rootScope.CIWindowData.push(
{
'multiwinid': windowviewid,
'IllustrationData': [],
'searchCIListViewData': [],
'CIImagePath': '',
'ImageSummary': '',
'moduleName': '',
'currentViewTitle': '',
'parentSlugName': '',
'currentSlug': '',
'imageId': '',
'imageName': '',
'isTextVisible': true,
'top': 0,
'left': 0,
'width': 0,
'height': 0,
'minimised': false,
'maximised': false
});
}
}
}
$scope.GetCIwindowStoreData = function (windowviewid, keyname) {
for (var x = 0 ; x < $rootScope.CIWindowData.length; x++) {
if ($rootScope.CIWindowData[x].multiwinid == windowviewid) {
return $rootScope.CIWindowData[x][keyname];
}
}
}
$scope.SetCIwindowStoreData = function (windowviewid, keyname, value) {
for (var x = 0 ; x < $rootScope.CIWindowData.length; x++) {
if ($rootScope.CIWindowData[x].multiwinid == windowviewid) {
$rootScope.CIWindowData[x][keyname] = value;
}
}
}
$rootScope.GetCIWindowId = function () {
// handle for single window
if ($rootScope.CIWindowData.length > 0) {
for (var x = 0 ; x < $rootScope.CIWindowData.length; x++) {
return $rootScope.CIWindowData[x].multiwinid;
}
}
else return 0;
}
$scope.DisableUI = function () {
var ciImagePanelConetent = document.getElementsByClassName("jsPanel-content");
for (var i = 0; i < ciImagePanelConetent.length; i++) {
ciImagePanelConetent[i].style.pointerEvents = "none";
ciImagePanelConetent[i].style.opacity = "0.7";
}
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
// CB module disable all
$('#CBDetailPageDiv').css('pointer-events', 'none');
$('#CBDetailPageDiv').css('opacity', '0.7');
}
$scope.EnableUI = function () {
var ciImagePanelConetent = document.getElementsByClassName("jsPanel-content");
for (var i = 0; i < ciImagePanelConetent.length; i++) {
ciImagePanelConetent[i].style.pointerEvents = "auto";
ciImagePanelConetent[i].style.opacity = "1";
}
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
// CB module enable all
$('#CBDetailPageDiv').css('pointer-events', 'auto');
$('#CBDetailPageDiv').css('opacity', '1');
}
$scope.loadAIModuleById = function (moduleId) {
$rootScope.isCallFromOtherModule = undefined;
$rootScope.MULTI_VIEW_ID += 1
// store exist module in module service
var ExistData = ModuleService.getModuleData("CLINICAL_ILLUSTRATIONS");
if (ExistData != undefined && ExistData.length > 0) {
// clear all module data before open new module in cb
ModuleService.ClearWinDataByModule(ExistData.mType);
}
var newWindowData = {
"mType": 'CLINICAL_ILLUSTRATIONS',
};
ModuleService.setModuleData(newWindowData, 0);
// close/remove prev panel when in minimised mode
var panelid = $(event.target).parent().parent().parent().parent().attr('id');
if (panelid != undefined) {
$scope.RemoveJSPanel(panelid);
}
$scope.initializeCIWindowData($rootScope.MULTI_VIEW_ID, true, undefined);
$scope.DisableUI();
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
// code that will be executed ...
// every time this view is loaded
//get current path
var currentURL = $location.path();
var selectedModuleName = '';
//set module title
angular.forEach($rootScope.userModules, function (value, key) {
if (value.slug === currentURL.replace('/', '')) {
selectedModuleName = value.name;
}
$rootScope.currentActiveModuleTitle = selectedModuleName;
})
$scope.SetCIwindowStoreData($rootScope.MULTI_VIEW_ID, 'moduleName', "Clinical Illustrations");
$scope.LoadCIJsonData($rootScope.MULTI_VIEW_ID);
$scope.CIAllBodyRegion = BodyRegions;
$scope.CIAllBodySystem = BodySystems;
$scope.CIAllOrientation = ViewOrientations;
$scope.CIAllImageType = ImageTypes;
$scope.CIAllSpeciality = MedicalSpecialties;
$scope.scroll();
//push the details of open module in array $rootScope.openModules
$rootScope.openModules.push({ "ModuleId": 4 });
//set the local storage
setTimeout(function () {
var curtab = $rootScope.getLocalStorageValue("currentCITabView");
if (curtab == 2) {
$scope.setActiveTab(2);
var curSelectedRowId = $rootScope.getLocalStorageValue("CISelectedRowId");
if (typeof (curSelectedRowId) !== "undefined" && curSelectedRowId !== null && curSelectedRowId !== '') {
$scope.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID);
$scope.idSelected = curSelectedRowId;
$scope.ReloadListViewImageDiv($scope.idSelected, $rootScope.MULTI_VIEW_ID);
}
else {
$scope.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID)
$scope.idSelected = '';
}
}
else {
$scope.setActiveTab(1);
$scope.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID);
}
}, 200);
}
$scope.reRunSearchOnLoad = function (windowviewid) {
var curBodyRegion = $rootScope.getLocalStorageValue("CICurBodyRegion");
if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null && curBodyRegion !== '') {
$scope.query.selectedbodyregion = curBodyRegion;
}
else {
$scope.query.selectedbodyregion = "";
}
var curBodySystem = $rootScope.getLocalStorageValue("CICurBodySystem");
if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null && curBodySystem !== '') {
$scope.query.selectedbodysystem = curBodySystem;
}
else {
$scope.query.selectedbodysystem = "";
}
var curOrientation = $rootScope.getLocalStorageValue("CICurOrientation");
if (typeof (curOrientation) !== "undefined" && curOrientation !== null && curOrientation !== '') {
$scope.query.selectedorientation = curOrientation;
}
else {
$scope.query.selectedorientation = "";
}
var curImageType = $rootScope.getLocalStorageValue("CICurImageType");
if (typeof (curImageType) !== "undefined" && curImageType !== null && curImageType !== '') {
$scope.query.selectedimagetype = curImageType;
}
else {
$scope.query.selectedimagetype = "";
}
var curSpeciality = $rootScope.getLocalStorageValue("CICurSpeciality");
if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null && curSpeciality !== '') {
$scope.query.selectedspecialty = curSpeciality;
}
else {
$scope.query.selectedspecialty = "";
}
if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedorientation == "" && $scope.query.selectedimagetype == "" && $scope.query.selectedspecialty == "") {
$scope.loadAllCI(windowviewid);
}
else {
$scope.ApplySearch($scope.query, windowviewid);
}
}
$scope.LoadCIJsonData = function (windowviewid) {
var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
promise.then(
function (result) {
var IllustrationData = new jinqJs()
.from(result.root.CIData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
$scope.SetCIwindowStoreData(windowviewid, 'IllustrationData', IllustrationData);
$scope.selectedCIListViewData = IllustrationData;
},
function (error) {
$scope.EnableUI();
// handle errors here
console.log(' $scope.IllustrationData = ' + error.statusText);
}
);
};
$scope.loadAllCI = function (windowviewid) {
$scope.selectedCIListViewData = $scope.GetCIwindowStoreData(windowviewid, 'IllustrationData');
$('#grid-view').empty();
var $e1 = $('
').appendTo('#grid-view');
$compile($e1)($scope);
$timeout(function ()
{
$('#' + $rootScope.getLocalStorageValue("currentImageId")).find('.thumbnail').addClass('HightLightThumbnail');
if ($rootScope.getLocalStorageValue('CIGridViewScroll') !== null && $location.url() == "/clinical-illustrations") {
$('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('CIGridViewScroll') });
}
}, 100);
$timeout(function () { $scope.EnableUI(); }, 400);
}
$scope.IsVisible = function () {
$scope.scroll();
}
$scope.showItem = function (id, windowviewid) {
if (windowviewid == undefined)
windowviewid = $rootScope.MULTI_VIEW_ID;
$scope.idSelected = id;
localStorage.setItem("CISelectedRowId", id);
//Set the vertical scroll value of the table.
var y = $('#ListViewDiv').scrollTop();
localStorage.setItem("CIListViewScroll", y);
$scope.hiderow = true;
if ($scope.filterstring == false) {
var SelectedCIthumbImage = [];
SelectedCIthumbImage = new jinqJs()
.from($scope.selectedCIListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCIthumbImage = "~/../content/images/ci/thumbnails/" + SelectedCIthumbImage[0]._ThumbnailImage;
$scope.SelectedCISummary = SelectedCIthumbImage[0]._Summary;
$scope.SelectedCIId = SelectedCIthumbImage[0]._id;
$scope.SelectedCITitle = SelectedCIthumbImage[0]._Title;
}
else
{
var searchCIListViewData = $scope.GetCIwindowStoreData(windowviewid, 'searchCIListViewData');
if (searchCIListViewData.length > 0) {
var SelectedCIthumbImage = [];
SelectedCIthumbImage = new jinqJs()
.from(searchCIListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCIthumbImage = "~/../content/images/ci/thumbnails/" + SelectedCIthumbImage[0]._ThumbnailImage;
$scope.SelectedCISummary = SelectedCIthumbImage[0]._Summary;
$scope.SelectedCIId = SelectedCIthumbImage[0]._id;
$scope.SelectedCITitle = SelectedCIthumbImage[0]._Title;
}
}
};
$scope.Reset = function (query, windowviewid) {
if (windowviewid == undefined) // call from also home controller list manager
windowviewid = $rootScope.MULTI_VIEW_ID;
$scope.DisableUI();
query.selectedbodyregion = "";
query.selectedbodysystem = "";
query.selectedorientation = "";
query.selectedimagetype = "";
query.selectedspecialty = "";
//set localstorage values
localStorage.setItem("CICurBodyRegion", '');
localStorage.setItem("CICurBodySystem", '');
localStorage.setItem("CICurOrientation", '');
localStorage.setItem("CICurImageType", '');
localStorage.setItem("CICurSpeciality", '');
localStorage.setItem("CISelectedRowId", "");
localStorage.setItem("CIListViewScroll", '');
if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); }
$('#ListViewDiv').scrollTop(0);
$scope.hideListViewDiv();
$scope.filterstring = false;
$scope.SetCIwindowStoreData(windowviewid, 'searchCIListViewData', []);
$scope.DisableUI();
$scope.loadAllCI(windowviewid);
}
$scope.ApplySearch = function (query, windowviewid) {
if (windowviewid == undefined) {
windowviewid = $rootScope.MULTI_VIEW_ID;
}
$scope.DisableUI();
$scope.filterstring = true;
$scope.SetCIwindowStoreData(windowviewid, 'searchCIListViewData', []);
filtercount = 0;
if (typeof (query.selectedbodyregion) !== "undefined" && (query.selectedbodyregion !== null && query.selectedbodyregion !== "")) {
filtercount = filtercount + 1;
localStorage.setItem("CICurBodyRegion", query.selectedbodyregion);
}
else {
localStorage.setItem("CICurBodyRegion", '');
}
if (typeof (query.selectedbodysystem) !== "undefined" && (query.selectedbodysystem !== null && query.selectedbodysystem !== "")) {
filtercount = filtercount + 1;
localStorage.setItem("CICurBodySystem", query.selectedbodysystem);
}
else {
localStorage.setItem("CICurBodySystem", '');
}
if (typeof (query.selectedorientation) !== "undefined" && (query.selectedorientation !== null && query.selectedorientation !== '')) {
filtercount = filtercount + 1;
localStorage.setItem("CICurOrientation", query.selectedorientation);
}
else {
localStorage.setItem("CICurOrientation", '');
}
if (typeof (query.selectedimagetype) !== "undefined" && (query.selectedimagetype !== null && query.selectedimagetype !== '')) {
filtercount = filtercount + 1;
localStorage.setItem("CICurImageType", query.selectedimagetype);
}
else {
localStorage.setItem("CICurImageType", '');
}
if (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null && query.selectedspecialty !== '')) {
filtercount = filtercount + 1;
localStorage.setItem("CICurSpeciality", query.selectedspecialty);
}
else {
localStorage.setItem("CICurSpeciality", '');
}
$scope.selectedCIListViewData = $scope.GetCIwindowStoreData(windowviewid, 'IllustrationData');
$('#grid-view').empty();
var cilistviewdata = [];
angular.forEach($scope.selectedCIListViewData, 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 (typeof (query.selectedspecialty) !== "undefined" && (query.selectedspecialty !== null && query.selectedspecialty !== "")) {
var posspeciality = value._MedicalSpecialty.indexOf(query.selectedspecialty);
if (posspeciality > -1) {
count = count + 1;
selectimg = true;
} else {
selectimg = false;
count = count - 1;
}
}
if (selectimg === true && count >= filtercount) {
$scope.imagePath = "~/../content/images/ci/thumbnails/" + value._ThumbnailImage;
var $el = $('').appendTo('#grid-view');
$compile($el)($scope);
$(".sidebar").mCustomScrollbar({
autoHideScrollbar: true,
//theme:"rounded"
});
cilistviewdata.push(
{
"_id": value._id,
"_ImageId": value._ImageId,
"_Title": value._Title,
"_contentImage": value._contentImage,
"_ThumbnailImage": value._ThumbnailImage,
"_BodySystem": value._BodySystem,
"_BodyRegion": value._BodyRegion,
"_ViewOrientation": value._ViewOrientation,
"_MedicalSpecialty": value._MedicalSpecialty,
"_ImageType": value._ImageType,
"_Summary": value._Summary
});
}
});
$('table > #ListViewDiv > #searchItem').remove();
$scope.SetCIwindowStoreData(windowviewid, 'searchCIListViewData', cilistviewdata);
$scope.searchCIListViewData = cilistviewdata;
//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);
$('table > #ListViewDiv > #searchItem').remove();
$('#ListViewDiv').append('No illustration found for the selected search criteria! |
');
}
$timeout(function () { $scope.EnableUI(); }, 400);
}
$scope.scroll = function () {
$("html,body").scrollTop(0);
}
$scope.openView = function ($event) {
var windowviewid = $rootScope.MULTI_VIEW_ID;
$rootScope.MenuModuleName = "CI";
$rootScope.disableAnnotationTB = false;
$rootScope.CIAnotationIdentifyModeOff = true;
if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
var selectedTileData = [];
selectedTileData = new jinqJs()
.from($scope.selectedCIListViewData)
.where('_id = ' + $event.currentTarget.id)
.select();
$rootScope.ViewTitle = selectedTileData[0]._Title;
}
else {
$rootScope.ViewTitle = $event.currentTarget.textContent;
}
// open module bu openresource
var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource');
if (isopenResourceRequest == "true") {
//set default module data
var CIDopenData = {
"id": $event.currentTarget.id,
"mType": 'CLINICAL_ILLUSTRATIONS',
"textVisible": true,
"windowTitle": $rootScope.ViewTitle,
"size": { height: 600, width: 900 }
};
window.parent.AIAModuleOpenResourceInfo(CIDopenData);
}
else
{
localStorage.setItem("currentViewTitle", $rootScope.ViewTitle);
localStorage.setItem("currentImageId", $event.currentTarget.id);
$scope.SetCIwindowStoreData(windowviewid, 'currentViewTitle', $rootScope.ViewTitle);
$scope.SetCIwindowStoreData(windowviewid, 'imageId', $event.currentTarget.id);
var imageName = selectedTileData[0]._contentImage;
$scope.SetCIwindowStoreData(windowviewid, 'imageName', imageName);
var imagePath = "~/../content/images/ci/images/" + imageName;
$scope.SetCIwindowStoreData(windowviewid, 'CIImagePath', imagePath);
var selectedImageCISummary = selectedTileData[0]._Summary
$scope.SetCIwindowStoreData(windowviewid, 'ImageSummary', selectedImageCISummary);
// store image for export
var tittle = $rootScope.getLocalStorageValue("currentViewTitle");
$rootScope.StoreTitleName(tittle);
$rootScope.StoreOrgImageName(imageName);
//Set the vertical scroll value of the Grid-View.
var y = $($window).scrollTop();
localStorage.setItem("CIGridViewScroll", y);
var u = $location.url();
$location.url('/clinical-illustrations-detail');
}
}
$rootScope.openCIBodyViewMain = function () {
if ($rootScope.isCallFromOtherModule) {
$scope.CIModuleData = ModuleService.getModuleData("CLINICAL_ILLUSTRATIONS");
$scope.readyToLoad = true;
$rootScope.CIWindowLoadComplete = false;
$scope.wincount = 1;
var winlen = $scope.CIModuleData.length;
var timeint = null;
timeint = $interval(function () {
if ($scope.readyToLoad == true) {
var windata = $scope.CIModuleData[$scope.wincount - 1];
$scope.openBodyView(windata);
}
$scope.readyToLoad = false;
if ($scope.wincount < winlen && $rootScope.CIWindowLoadComplete == true) {
$scope.wincount = $scope.wincount + 1;
$rootScope.CIWindowLoadComplete = false;
$scope.readyToLoad = true;
}
if ($scope.wincount == winlen && $rootScope.CIWindowLoadComplete == true) {
$scope.stopInterval();
$scope.$emit("LoadModuleComplete", "CLINICAL_ILLUSTRATIONS");
}
}, 100);
$scope.stopInterval = function () {
if (angular.isDefined(timeint)) {
$interval.cancel(timeint);
timeint = undefined;
}
};
}
else {
$scope.openBodyView(null);
}
}
$scope.openBodyView = function (ciModuleData) {
if ($rootScope.isCallFromOtherModule == true) {
$scope.ciOpenInOtherModules = ciModuleData;
$rootScope.MULTI_VIEW_ID += 1;
var windowviewid = $rootScope.MULTI_VIEW_ID;
$scope.initializeCIWindowData(windowviewid, false, $scope.ciOpenInOtherModules.currentWindowId);
var moduleName = $scope.ciOpenInOtherModules.mType;
$scope.SetCIwindowStoreData(windowviewid, 'moduleName', moduleName);
var promise = DataService.getJson('~/../content/data/json/ci/ci_dat_contentlist.json')
promise.then(
function (result) {
var IllustrationData = new jinqJs()
.from(result.root.CIData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
// serial no of imageid
var imageId = $scope.ciOpenInOtherModules.id;
$scope.SetCIwindowStoreData(windowviewid, 'imageId', imageId);
var selectedTileData = [];
selectedTileData = new jinqJs()
.from(IllustrationData)
.where('_id == ' + imageId)
.select();
var imageName = selectedTileData[0]._contentImage;
$scope.SetCIwindowStoreData(windowviewid, 'imageName', imageName);
var imagePath = "~/../content/images/ci/images/" + imageName;
$scope.SetCIwindowStoreData(windowviewid, 'CIImagePath', imagePath);
var selectedImageCISummary = selectedTileData[0]._Summary
$scope.SetCIwindowStoreData(windowviewid, 'ImageSummary', selectedImageCISummary);
var isTextVisible = $scope.ciOpenInOtherModules.textVisible;
$scope.SetCIwindowStoreData(windowviewid, 'isTextVisible', isTextVisible);
var ciTitle = $scope.ciOpenInOtherModules.anatomyTitle;
$scope.SetCIwindowStoreData(windowviewid, 'currentViewTitle', ciTitle);
localStorage.setItem("currentViewTitle", ciTitle);
var isMaximize = $scope.ciOpenInOtherModules.maximised;
var isMinimize = $scope.ciOpenInOtherModules.minimised;
$scope.SetCIwindowStoreData(windowviewid, 'maximised', isMaximize);
$scope.SetCIwindowStoreData(windowviewid, 'minimised', isMinimize);
// store image for export
$rootScope.StoreTitleName(ciTitle);
$rootScope.StoreOrgImageName(selectedTileData[0]._contentImage);
$scope.SetCIwindowStoreData(windowviewid, 'parentSlugName', ($location.url()).replace('/', ''));
$scope.loadCIllustration(windowviewid);
},
function (error) {
// handle errors here
console.log(' $scope.CIllustrationData = ' + error.statusText);
}
);
}
else {
$scope.SetCIwindowStoreData($rootScope.MULTI_VIEW_ID, 'parentSlugName', 'clinical-illustrations');
$scope.loadCIllustration($rootScope.MULTI_VIEW_ID);
}
}
$scope.loadCIllustration = function (windowviewid) {
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
$scope.jsPanelID = 'ciImagePanel' + '_' + windowviewid;
var selectedCIImage = $scope.GetCIwindowStoreData(windowviewid, 'CIImagePath');
var selectedImageCISummary = $scope.GetCIwindowStoreData(windowviewid, 'ImageSummary');
var tittle = $scope.GetCIwindowStoreData(windowviewid, 'currentViewTitle');
var imageId = $scope.GetCIwindowStoreData(windowviewid, 'imageId');
if ($rootScope.isCallFromOtherModule) {
// open JS panel for curriculum with define cornonate in CB jason
$scope.jsPanelWidth = $scope.ciOpenInOtherModules.size.width;//1000;
$scope.jsPanelHeight = $scope.ciOpenInOtherModules.size.height;
if ($scope.ciOpenInOtherModules.size.height > 540)
$scope.jsPanelHeight = 540;
$scope.jsPanelLeft = 320;
$scope.jsPanelTop = $rootScope.cBModulejsPanelTop();
}
else {
$scope.jsPanelWidth = $(window).outerWidth() - 30;
$scope.jsPanelHeight = $(window).outerHeight() - 125;
$scope.jsPanelLeft = 15;
$scope.jsPanelTop = 70;
}
$scope.jsPanelCI = $.jsPanel({
id: $scope.jsPanelID,
selector: '.ciView',
theme: 'success',
currentController: 'CIController',
parentSlug: $scope.GetCIwindowStoreData(windowviewid, 'parentSlugName'),
content: '
' +
'
' +
'

' +
'
' + selectedImageCISummary + '
' +
'
' +
'
',
title: tittle,
position: {
top: $scope.jsPanelTop,
left: $scope.jsPanelLeft
},
size: {
width: $scope.jsPanelWidth,
height: $scope.jsPanelHeight
},
});
var isMaximize = $scope.GetCIwindowStoreData(windowviewid, 'maximised');
var isMinimize = $scope.GetCIwindowStoreData(windowviewid, 'minimised');
if (isMaximize) {
$scope.jsPanelCI.maximize();
}
else if (isMinimize) {
$scope.jsPanelCI.minimize();
}
else {
$scope.jsPanelCI.normalize();
}
$scope.SetCIwindowStoreData(windowviewid, 'top', $scope.jsPanelTop);
$scope.SetCIwindowStoreData(windowviewid, 'left', $scope.jsPanelLeft);
$scope.SetCIwindowStoreData(windowviewid, 'width', $scope.jsPanelWidth);
$scope.SetCIwindowStoreData(windowviewid, 'height', $scope.jsPanelHeight);
$scope.SetCIwindowStoreData(windowviewid, 'currentSlug', 'clinical-illustrations-detail');
$rootScope.openViews.push(
{
"module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": imageId,
"slug": $scope.GetCIwindowStoreData(windowviewid, 'currentSlug')
});
$("#" + $scope.jsPanelID + " .img-thumbnail").css("height", $("#" + $scope.jsPanelID + " .jsPanel-content").height());
if (!$rootScope.isCallFromOtherModule) {
$('#CIView').css("height", $(window).outerHeight() - 65);
$('#CIView').css("width", $(window).outerWidth() - 46);
}
if ($rootScope.isCallFromOtherModule) {
var canvasDIvHeight = parseInt($("#" + $scope.jsPanelID).outerHeight()) - 40;
}
else {
var canvasDIvHeight = parseInt($("#" + $scope.jsPanelID).outerHeight()) - 90;
}
$('#canvasDivCI_' + windowviewid).css('height', canvasDIvHeight);
$('#canvasDivCI_' + windowviewid + ' img').load(function () {
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
//if ($rootScope.isCallFromOtherModule) {
// $scope.JsPanelclick(windowviewid);
//}
$scope.JsPanelclick(windowviewid);
$scope.$emit("cBEnableDisableMenuOption", $scope.jsPanelID);
$rootScope.CIWindowLoadComplete = true;
var isTextVisible = $scope.GetCIwindowStoreData(windowviewid, 'isTextVisible');
if (isTextVisible) {
$("#btnTxtOnOff_" + windowviewid).text("Text Off"); $("#sid_" + windowviewid).css("visibility", "visible");
}
else {
$("#btnTxtOnOff_" + windowviewid).text("Text On"); $("#sid_" + windowviewid).css("visibility", "hidden");
}
});
//Calling methode for save Js Panel Activity for SaveCB
$scope.PanelActivity();
}
$scope.$on('annotationToolEvent', function (event, data) {
$('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(255,255,255)")
$('#editstylebackgroundcolor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" });
$('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(0,0,0)")
$('#outlineColor .minicolors >.minicolors-panel > .minicolors-grid >.minicolors-picker').css({ "top": "145px", "left": "4px" });
$('#canvasCI_' + $rootScope.MULTI_VIEW_ID).css("display", "block");
$('#canvasPaintCI_' + $rootScope.MULTI_VIEW_ID).css("display", "block");
$rootScope.onDrawingCanvasClick();
});
$scope.ReloadListViewImageDiv = function (id, windowviewid) {
//console.log(id);
$scope.idSelected = id;
$scope.hiderow = true;
var IllustrationData = $scope.GetCIwindowStoreData(windowviewid, 'IllustrationData');
var SelectedCIthumbImage = [];
SelectedCIthumbImage = new jinqJs()
.from(IllustrationData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCIthumbImage = "~/../content/images/ci/thumbnails/" + SelectedCIthumbImage[0]._ThumbnailImage;
$scope.SelectedCISummary = SelectedCIthumbImage[0]._Summary;
$scope.SelectedCIId = SelectedCIthumbImage[0]._id;
$scope.SelectedCITitle = SelectedCIthumbImage[0]._Title;
//Set the scroll position of the tablebody to show selected row.
var curCIListViewScroll = $rootScope.getLocalStorageValue("CIListViewScroll");
if (typeof (curCIListViewScroll) !== "undefined" && curCIListViewScroll !== null && curCIListViewScroll !== '') {
if (typeof InstallTrigger !== 'undefined')
{
$('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue("CIListViewScroll") });
}
else
{
$('#ListViewDiv').scrollTop($rootScope.getLocalStorageValue("CIListViewScroll"));
}
}
};
$scope.hideListViewDiv = function () {
if ($rootScope.getLocalStorageValue("currentCITabView") == 2) {
localStorage.setItem("CISelectedRowId", "");
if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); }
$scope.hiderow = false;
}
}
$scope.JsPanelclick = function (windowviewid) {
// call from while open module in CB
$("#ciImagePanel_" + windowviewid).on('click', function (event) {
var pnlName = event.currentTarget.id;
$scope.$emit("cBEnableDisableMenuOption", pnlName);
// store image for export while click on panel
var currentViewTitle = $scope.GetCIwindowStoreData(windowviewid, 'currentViewTitle');
var imageName = $scope.GetCIwindowStoreData(windowviewid, 'imageName');
$rootScope.StoreTitleName(currentViewTitle);
$rootScope.StoreOrgImageName(imageName);
});
}
$scope.GetTextVisiblity = function (windowviewid, btnTextValue) {
var isVisible;
if (btnTextValue == "Text On") {
isVisible = false;
$scope.SetCIwindowStoreData(windowviewid, 'isTextVisible', isVisible);
} else {
isVisible = true;
$scope.SetCIwindowStoreData(windowviewid, 'isTextVisible', isVisible);
}
//$rootScope.saveCIWindowActivity("textVisible", isVisible);
}
$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.CIWindowData.length; index++) {
if ($rootScope.CIWindowData[index].multiwinid == windowviewid) {
if (index != -1) {
// remove module which one is loaded
$scope.CIWindowData.splice(index, 1);
if ($('#' + panelid).html() != undefined) {
$('#' + panelid).remove();
}
$rootScope.resetjsPanelTop();
}
}
}
}
//Created method by Sandeep for Save JSPanel Activity on the CB module
$scope.PanelActivity = function () {
$("#" + $scope.jsPanelID).resizable({
stop: function (event, ui) {
var len = (event.currentTarget.id).split("_").length;
var windowviewid = (event.currentTarget.id).split("_")[len - 1];
$scope.SetCIwindowStoreData(windowviewid, 'width', ui.size.width);
$scope.SetCIwindowStoreData(windowviewid, 'height', ui.size.height);
}
});
$("#" + $scope.jsPanelID).draggable({
stop: function (event, ui) {
//var jsPanelID = $(this).attr("id");
var len = (event.currentTarget.id).split("_").length;
var windowviewid = (event.currentTarget.id).split("_")[len - 1];
//var offSets = $(this).offset(); var postions = (this).position(); (this).offsetTop (this).offsetLeft
$scope.SetCIwindowStoreData(windowviewid, 'top', ui.position.top);
$scope.SetCIwindowStoreData(windowviewid, 'left', ui.position.left);
}
});
$(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);
});
$(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-max .jsglyph-maximize", function (event) {
var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id');
var len = (currentPanelId).split("_").length;
var windowviewid = (currentPanelId).split("_")[len - 1];
$scope.SetCIwindowStoreData(windowviewid, 'maximised', true);
$scope.SetCIwindowStoreData(windowviewid, 'minimised', false);
});
$(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-min #minSpan", function (event) {
var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id');
var len = (currentPanelId).split("_").length;
var windowviewid = (currentPanelId).split("_")[len - 1];
$scope.SetCIwindowStoreData(windowviewid, 'maximised', false);
$scope.SetCIwindowStoreData(windowviewid, 'minimised', true);
});
$(document).on("click", "#" + $scope.jsPanelID + " .jsPanel-hdr .jsPanel-hdr-r .jsPanel-btn-norm .jsglyph-normalize", function (event) {
var currentPanelId = $(event.target).parent().parent().parent().parent().attr('id');
var len = (currentPanelId).split("_").length;
var windowviewid = (currentPanelId).split("_")[len - 1];
$scope.SetCIwindowStoreData(windowviewid, 'maximised', false);
$scope.SetCIwindowStoreData(windowviewid, 'minimised', false);
});
}
}]
);
function GetTextVisibityCI(event) {
var scope = angular.element(document.getElementById("CIView")).scope();
// var len = (event.target.id).split("_").length;
var windowviewid = (event.target.id).split("_")[1];
var btnTextValue = event.target.innerText;
scope.$apply(function () {
scope.GetTextVisiblity(windowviewid,btnTextValue);
});
}