AIA.controller("CAController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "pages", "BodyRegions", "BodySystems", "MedicalSpecialties", "DataService", "ModuleService", "$interval",
function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, pages, BodyRegions, BodySystems, MedicalSpecialties, DataService, ModuleService, $interval) {
$scope.showTabButton = true;
$scope.AnimationData;
$scope.CAAllBodyRegion = [];
$scope.CAAllBodySystem = [];
$scope.CAAllSpeciality = [];
$scope.selectedCAListViewData = [];
$scope.SelectedCAthumbImage = [];
$scope.SelectedCAImage = [];
$scope.SelectedCASummary = [];
$scope.filterstring = false;
$scope.islinkActive = false;
$scope.hostedServer = "https://ssl.adam.com/graphics/Multimedia/en/";
$scope.hostedFolderId;
$scope.idSelected;
$scope.query = {
selectedbodyregion: '',
selectedbodysystem: '',
selectedspecialty: '',
};
$scope.setActiveTab = function (tabToSet) {
if(tabToSet=="" ||tabToSet==undefined)
{
$scope.activeTab=1;
}
else
{
$scope.activeTab = tabToSet;
}
localStorage.setItem("currentCATabView", $scope.activeTab);
if ($scope.activeTab == 1) {
$('#grid-view').css("display", "block");
$('#list-view').css("display", "none");
}
else {
$('#grid-view').css("display", "none");
$('#list-view').css("display", "block");
}
};
$scope.ObjectAttribute=function(windowviewid)
{
var windata={
'multiwinid': windowviewid,
'AnimationData': [],
'searchCAListViewData': [],
'CAImagePath': '',
'moduleName': '',
'currentViewTitle': '',
'parentSlugName': '',
'currentSlug': '',
'imageId': '',
'imageName': '',
'clickedCAVideo': '',
'clickedCASummary': '',
'hostedFolderId': '',
'isTextVisible': true,
'y': 0,
'x': 0,
'width': 0,
'height': 0,
'minimised': false,
'maximised': true,
'minmaxAutoEvent':true,
};
return windata;
}
$scope.initializeCAWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) {
if (isOpenWithExistsModule || openPanelNo == 0) {
if ($rootScope.CAWindowData != undefined) {
$rootScope.CAWindowData.length = 0;
}
else {
$rootScope.CAWindowData = [];
}
$rootScope.CAWindowData.push($scope.ObjectAttribute(windowviewid));
}
else {
var isNewWindow = true;
for (var k = 0; k < $rootScope.CAWindowData.length; k++) {
if ($rootScope.CAWindowData[k].multiwinid == windowviewid) {
isNewWindow = false;
break;
}
}
if (isNewWindow) {
$rootScope.CAWindowData.push($scope.ObjectAttribute(windowviewid));
}
}
}
$scope.GetCAwindowStoreData = function (windowviewid, keyname) {
for (var x = 0 ; x < $rootScope.CAWindowData.length; x++) {
if ($rootScope.CAWindowData[x].multiwinid == windowviewid) {
return $rootScope.CAWindowData[x][keyname];
}
}
}
$scope.SetCAwindowStoreData = function (windowviewid, keyname, value) {
for (var x = 0 ; x < $rootScope.CAWindowData.length; x++) {
if ($rootScope.CAWindowData[x].multiwinid == windowviewid) {
$rootScope.CAWindowData[x][keyname] = value;
}
}
}
// access from home controller
$rootScope.SetCAwindowData=function(windowviewid,keyname,data) {
for(var x=0 ;x < $rootScope.CAWindowData.length;x++){
if($rootScope.CAWindowData[x].multiwinid==windowviewid)
{
$rootScope.CAWindowData[x][keyname]=data;
}
}
}
$scope.DisableUI = function () {
var caImagePanelConetent = document.getElementsByClassName("jsPanel-content");
for (var i = 0; i < caImagePanelConetent.length; i++) {
caImagePanelConetent[i].style.pointerEvents = "none";
caImagePanelConetent[i].style.opacity = "0.7";
}
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
// CB module disable all
$('#HomeContainerDiv').css('pointer-events', 'none');
$('#HomeContainerDiv').css('opacity', '0.7');
}
$scope.EnableUI = function () {
var caImagePanelConetent = document.getElementsByClassName("jsPanel-content");
for (var i = 0; i < caImagePanelConetent.length; i++) {
caImagePanelConetent[i].style.pointerEvents = "auto";
caImagePanelConetent[i].style.opacity = "1";
}
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
// CB module enable all
$('#HomeContainerDiv').css('pointer-events', 'auto');
$('#HomeContainerDiv').css('opacity', '1');
}
$scope.loadAIModuleById = function (moduleId) {
//added by birendra
//direct open CA module
var curtab = $rootScope.getLocalStorageValue("currentCATabView");
$scope.setActiveTab(curtab)
if($rootScope.siteUrlInfo.mType!=null && $rootScope.siteUrlInfo.id!=null)
{
if($rootScope.siteUrlInfo.mType.toLowerCase()=='ca' && $rootScope.siteUrlInfo.id!="")
{
$rootScope.isCallFromOtherModule = true;
$rootScope.linkToOpenCa=true;
// store exist module in module service
var ExistData = ModuleService.getModuleData("CLINICAL_ANIMATIONS");
if (ExistData != undefined && ExistData.length > 0) {
// clear all module data before open new module in cb
ModuleService.ClearWinDataByModule(ExistData.mType);
}
var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
promise.then(
function (result) {
var AnimationTitle = new jinqJs()
.from(result.root.CAData)
.where('_id = ' + $rootScope.siteUrlInfo.id)
.select('_Title');
if(AnimationTitle.length>0)
{
var CAlinkData = {
"id": $rootScope.siteUrlInfo.id,
"mType": 'CLINICAL_ANIMATIONS',
"textVisible": true,
"maximised": true,
"windowTitle": AnimationTitle[0]._Title,
};
ModuleService.setModuleData(CAlinkData, 0);
// close/remove prev panel when in minimised mode
if($rootScope.CAWindowData!=undefined)
{
if($rootScope.CAWindowData.length>0)
{
for(var x=0 ;x < $rootScope.CAWindowData.length;x++){
var winid=$rootScope.CAWindowData[x].multiwinid;
if ($('#caImagePanel_' + winid).html() != undefined) {
$('#caImagePanel_' + winid).remove();
}
}
$rootScope.CAWindowData=[];
}
}
$location.url('/clinical-animations-detail');
}
else
{
$("#messageModal div div .modal-header button").css('display','none');
$('#errorMessage').text("Animation course not found. Please try again!");
$("#messageModal").modal('show');
//logout if not course found
$("#messageModal div div .modal-footer button").on('click', function (event) {
$rootScope.LogoutUser();
});
}
},
function (error) {
$scope.EnableUI();
// handle errors here
console.log(' $scope.AnimationData = ' + error.statusText);
});
}
else
{
$scope.loadCAlist();
}
}
else
{
$scope.loadCAlist();
}
};
$scope.loadCAlist = function () {
$rootScope.isCallFromOtherModule = undefined;
$('.breadcrumb').css('display','block');
$('.tab-content').css('display','block');
$rootScope.MULTI_VIEW_ID += 1
// store exist module in module service
var ExistData = ModuleService.getModuleData("CLINICAL_ANIMATIONS");
if (ExistData != undefined && ExistData.length > 0) {
// clear all module data before open new module in cb
ModuleService.ClearWinDataByModule(ExistData.mType);
}
var newWindowData = {
"mType": 'CLINICAL_ANIMATIONS',
};
ModuleService.setModuleData(newWindowData, 0);
// close/remove prev panel when in minimised mode
if($rootScope.CAWindowData!=undefined)
{
if($rootScope.CAWindowData.length>0)
{
for(var x=0 ;x < $rootScope.CAWindowData.length;x++){
var winid=$rootScope.CAWindowData[x].multiwinid;
if ($('#caImagePanel_' + winid).html() != undefined) {
$('#caImagePanel_' + winid).remove();
}
}
$rootScope.CAWindowData=[];
}
}
$scope.initializeCAWindowData($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.SetCAwindowStoreData($rootScope.MULTI_VIEW_ID, 'moduleName', "CLINICAL_ANIMATIONS");
$scope.LoadCAJsonData($rootScope.MULTI_VIEW_ID);
$scope.CAAllBodyRegion = BodyRegions;
$scope.CAAllBodySystem = BodySystems;
$scope.CAAllSpeciality = MedicalSpecialties;
$scope.scroll();
//push the details of open module in array $rootScope.openModules
$rootScope.openModules.push({ "ModuleId": 5 });
//set the local storage
setTimeout(function () {
var curtab = $rootScope.getLocalStorageValue("currentCATabView");
//call time interval function until load Illustration data
var timeintval = null;
timeintval = $interval(function () {
var AnimationData = $scope.GetCAwindowStoreData($rootScope.MULTI_VIEW_ID, 'AnimationData');
if(AnimationData==undefined){$scope.stopIntervalCA();}
if (AnimationData.length>0) {
$scope.stopIntervalCA();
if (curtab == 2) {
var curSelectedRowId = $rootScope.getLocalStorageValue("CASelectedRowId");
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.reRunSearchOnLoad($rootScope.MULTI_VIEW_ID);
}
}
else
{
console.log("waiting for Animation Data");
}
}, 100);
$scope.stopIntervalCA = function () {
if (angular.isDefined(timeintval)) {
$interval.cancel(timeintval);
timeintval = undefined;
}
};
}, 200);
}
$scope.reRunSearchOnLoad = function (windowviewid) {
var curBodyRegion = $rootScope.getLocalStorageValue("CACurBodyRegion");
if (typeof (curBodyRegion) !== "undefined" && curBodyRegion !== null && curBodyRegion !== '') {
$scope.query.selectedbodyregion = curBodyRegion;
}
else {
$scope.query.selectedbodyregion = "";
}
var curBodySystem = $rootScope.getLocalStorageValue("CACurBodySystem");
if (typeof (curBodySystem) !== "undefined" && curBodySystem !== null && curBodySystem !== '') {
$scope.query.selectedbodysystem = curBodySystem;
}
else {
$scope.query.selectedbodysystem = "";
}
var curSpeciality = $rootScope.getLocalStorageValue("CACurSpeciality");
if (typeof (curSpeciality) !== "undefined" && curSpeciality !== null && curSpeciality !== '') {
$scope.query.selectedspecialty = curSpeciality;
}
else {
$scope.query.selectedspecialty = "";
}
if ($scope.query.selectedbodyregion == "" && $scope.query.selectedbodysystem == "" && $scope.query.selectedspecialty == "") {
$scope.loadAllCA(windowviewid);
}
else {
$scope.ApplySearch($scope.query);
}
}
$scope.LoadCAJsonData = function (windowviewid) {
var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist.json')
promise.then(
function (result) {
if($rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2 && $rootScope.userData.StudentEdition!= null && $rootScope.userData.StudentEdition.length>0)
{
$scope.islinkActive = true;
var AnimationData = new jinqJs()
.from(result.root.CAData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select('_id','_BodyRegion','_BodySystem','_ImageId','_LowerSummary','_MedicalSpecialty','_Summary','_ThumbnailImage','_Title','_Video','copyLink');
angular.forEach(AnimationData, function (value, key) {
AnimationData[key].copyLink=$rootScope.homeURL+'?accountNumber='+$rootScope.userData.LicenseInfo.AccountNumber.trim()+'&edition='+$rootScope.userData.StudentEdition[0]+'&referer=&mType=CA&id='+value._id;
});
}
else
{
var AnimationData = new jinqJs()
.from(result.root.CAData)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
}
$scope.SetCAwindowStoreData(windowviewid, 'AnimationData', AnimationData);
$scope.selectedCAListViewData = AnimationData;
},
function (error) {
$scope.EnableUI();
// handle errors here
console.log(' $scope.AnimationData = ' + error.statusText);
});
};
$scope.loadAllCA = function (windowviewid) {
$scope.selectedCAListViewData = $scope.GetCAwindowStoreData(windowviewid, 'AnimationData');
$('#grid-view').empty();
angular.forEach($scope.selectedCAListViewData, function (value, key) {
var imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
if($rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2 && $rootScope.userData.StudentEdition!= null && $rootScope.userData.StudentEdition.length>0)
{
var $el = $('
'
+'
'
+'
'
+'Copy embed link '
+'
'
+'
').appendTo('#grid-view');
$compile($el)($scope);
}
else
{
//site license and super admin section
//site license not has loginId and super admin not has accountNumber
var $el = $('').appendTo('#grid-view');
$compile($el)($scope);
}
$(".sidebar").mCustomScrollbar({
autoHideScrollbar: true,
//theme:"rounded"
});
});
$('#' + $rootScope.getLocalStorageValue("currentBodyViewId")).find('.thumbnail').addClass('HightLightThumbnail');
$timeout(function () {
if ($rootScope.getLocalStorageValue('CAGridViewScroll') !== null && $location.url() == "/clinical-animations") {
$("#grid-view").animate({ scrollTop: $rootScope.getLocalStorageValue('CAGridViewScroll') }, 'slow');
}
},
200);
$timeout(function () {
$scope.EnableUI();
$rootScope.ResetGridListLength();
}, 400);
}
$scope.IsVisible = function () {
$scope.scroll();
}
$scope.showItem = function (id, windowviewid) {
if (windowviewid == undefined)
windowviewid = $rootScope.MULTI_VIEW_ID;
$scope.idSelected = id;
localStorage.setItem("CASelectedRowId", id);
//Set the vertical scroll value of the table.
var y = $('#ListViewDiv').scrollTop();
localStorage.setItem("CAListViewScroll", y);
$scope.hiderow = true;
if ($scope.filterstring == false) {
var SelectedCAthumbImage = [];
SelectedCAthumbImage = new jinqJs()
.from($scope.selectedCAListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
$scope.SelectedCASummary = SelectedCAthumbImage[0]._Summary;
$scope.SelectedCAId = SelectedCAthumbImage[0]._id;
$scope.SelectedCATitle = SelectedCAthumbImage[0]._Title;
}
else {
var searchCAListViewData = $scope.GetCAwindowStoreData(windowviewid, 'searchCAListViewData');
if (searchCAListViewData.length > 0) {
var SelectedCAthumbImage = [];
SelectedCAthumbImage = new jinqJs()
.from(searchCAListViewData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
$scope.SelectedCASummary = SelectedCAthumbImage[0]._Summary;
$scope.SelectedCAId = SelectedCAthumbImage[0]._id;
$scope.SelectedCATitle = SelectedCAthumbImage[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.selectedspecialty = "";
//set localstorage values
localStorage.setItem("CACurBodyRegion", '');
localStorage.setItem("CACurBodySystem", '');
localStorage.setItem("CACurSpeciality", '');
localStorage.setItem("CAListViewScroll", '');
localStorage.setItem("CASelectedRowId", "");
$scope.filterstring = false;
if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); }
$('#ListViewDiv').scrollTop(0);
$scope.hideListViewDiv();
$scope.SetCAwindowStoreData(windowviewid, 'searchCAListViewData', []);
if ($rootScope.getLocalStorageValue("currentCATabView") == 2) {
localStorage.setItem("CASelectedRowId", "");
$scope.hiderow = false;
}
setTimeout(function(){
$scope.loadAllCA(windowviewid);
},200)
}
$scope.ApplySearch = function (query, windowviewid) {
$scope.DisableUI();
if (windowviewid == undefined) {
windowviewid = $rootScope.MULTI_VIEW_ID;
}
setTimeout(function(){
$scope.FilterSearch(query, windowviewid)
},200)
}
// for "Intracytoplasmic sperm injection (ICSI)" case, the Body region is not required so we have added "_BodyRegion": "None" which was actually not available in origincal flex file.
$scope.FilterSearch = function (query, windowviewid) {
$scope.filterstring = true;
$scope.SetCAwindowStoreData(windowviewid, 'searchCAListViewData', []);
filtercount = 0;
if (typeof (query.selectedbodyregion) !== "undefined" && query.selectedbodyregion !== null && query.selectedbodyregion !== "") {
filtercount = filtercount + 1;
localStorage.setItem("CACurBodyRegion", query.selectedbodyregion);
}
else {
localStorage.setItem("CACurBodyRegion", '');
}
if (typeof (query.selectedbodysystem) !== "undefined" && query.selectedbodysystem !== null && query.selectedbodysystem !== "") {
filtercount = filtercount + 1;
localStorage.setItem("CACurBodySystem", query.selectedbodysystem);
}
else {
localStorage.setItem("CACurBodySystem", '');
}
if (typeof (query.selectedspecialty) !== "undefined" && query.selectedspecialty !== null && query.selectedspecialty !== "") {
filtercount = filtercount + 1;
localStorage.setItem("CACurSpeciality", query.selectedspecialty);
}
else {
localStorage.setItem("CACurSpeciality", '');
}
$scope.selectedCAListViewData = $scope.GetCAwindowStoreData(windowviewid, 'AnimationData');
$('#grid-view').empty();
var calistviewdata = [];
angular.forEach($scope.selectedCAListViewData, 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.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) {
var imagePath = "~/../content/images/ca/thumbnails/" + value._ThumbnailImage;
if($rootScope.userData.LicenseInfo!= null && $rootScope.userData.EditionId<=2 && $rootScope.userData.StudentEdition!= null && $rootScope.userData.StudentEdition.length>0)
{
var $el = $(''
+'
'
+'
'
+'Copy embed link '
+'
'
+'
').appendTo('#grid-view');
$compile($el)($scope);
}
else
{
//site license and super admin section
//site license not has loginId and super admin not has accountNumber
var $el = $('').appendTo('#grid-view');
$compile($el)($scope);
}
$(".sidebar").mCustomScrollbar({
autoHideScrollbar: true,
//theme:"rounded"
});
calistviewdata.push(
{
"_id": value._id,
"_ImageId": value._ImageId,
"_Title": value._Title,
"_Video": value._Video,
"_ThumbnailImage": value._ThumbnailImage,
"_BodySystem": value._BodySystem,
"_BodyRegion": value._BodyRegion,
"_MedicalSpecialty": value._MedicalSpecialty,
"_Summary": value._Summary,
"_LowerSummary": value._LowerSummary
});
}
});
$('table > #ListViewDiv > #searchAnimation').remove();
$scope.SetCAwindowStoreData(windowviewid, 'searchCAListViewData', calistviewdata);
$scope.searchCAListViewData = calistviewdata;
//Show Error Message in case of gridview if no data is found
if ($scope.searchCAListViewData.length == 0) {
var $el = $('No animation found for the selected search criteria!
').appendTo('#grid-view');
$compile($el)($scope);
$('table > #ListViewDiv > #searchAnimation').remove();
$('#ListViewDiv').append('No animation found for the selected search criteria! ');
}
$timeout(function () {
$scope.EnableUI();
$rootScope.ResetGridListLength();
}, 500);
}
$rootScope.ResetGridListLength=function()
{
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
var srchHeight=$('.breadcrumb').height();
var gridheight=screen.height-srchHeight-128;
var listheight=screen.height-srchHeight-352;
$('#grid-view').css({"height":gridheight,"overflow":"auto"});
$('#ListViewDiv').css({"height":listheight,"overflow":"auto"});
}
else
{
var srchHeight=$('.breadcrumb').height();
var gridheight=screen.height-srchHeight-276;
var listheight=screen.height-srchHeight-500;
$('#grid-view').css({"height":gridheight,"overflow":"auto"});
$('#ListViewDiv').css({"height":listheight,"overflow":"auto"});
}
}
$scope.scroll = function () {
$("html,body").scrollTop(0);
}
$scope.openView = function ($event) {
var windowviewid = $rootScope.MULTI_VIEW_ID;
$rootScope.disableAnnotationTBFn();
$rootScope.MenuModuleName = "CA";
$rootScope.currentBodyViewId = $event.currentTarget.id;
if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
var selectedTileData = [];
selectedTileData = new jinqJs()
.from($scope.selectedCAListViewData)
.where('_id = ' + $event.currentTarget.id)
.select();
$rootScope.ViewTitle = selectedTileData[0]._Title;
}
else {
$rootScope.ViewTitle = $event.currentTarget.textContent;
}
var isopenResourceRequest = sessionStorage.getItem('isModuleOpenByOpenResource');
if (isopenResourceRequest == "true") {
//set default module data
var CADopenData = {
"id": $event.currentTarget.id,
"mType": 'CLINICAL_ANIMATIONS',
"textVisible": true,
"windowTitle": $rootScope.ViewTitle,
"size": { height: 600, width: 900 },
"position": { x: 1, y: 30 }
};
window.parent.AIAModuleOpenResourceInfo(CADopenData);
}
else
{
localStorage.setItem("currentViewTitle", $rootScope.ViewTitle);
localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
$scope.SetCAwindowStoreData(windowviewid, 'currentViewTitle', $rootScope.ViewTitle);
$scope.SetCAwindowStoreData(windowviewid, 'imageId', $event.currentTarget.id);
var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist_mp4link.json')
promise.then(
function (result) {
// $scope.AnimationData = result;
$scope.CAlistViewData = result.root.CAData;
var id = $scope.GetCAwindowStoreData(windowviewid, 'imageId');
var clickedCAVideoData = [];
clickedCAVideoData = new jinqJs()
.from($scope.CAlistViewData)
.where('_id == ' + id)
.select('_Video', '_LowerSummary', '_HostedFolderId');
var clickedCAVideo = clickedCAVideoData[0]._Video;
var clickedCASummary = clickedCAVideoData[0]._LowerSummary;
var hostedFolderId = clickedCAVideoData[0]._HostedFolderId;
$scope.SetCAwindowStoreData(windowviewid, 'clickedCAVideo', clickedCAVideo);
$scope.SetCAwindowStoreData(windowviewid, 'clickedCASummary', clickedCASummary);
$scope.SetCAwindowStoreData(windowviewid, 'hostedFolderId', hostedFolderId);
var CAGridViewScrollPosition = $("#grid-view").scrollTop();
localStorage.setItem('CAGridViewScroll', CAGridViewScrollPosition);
var u = $location.url();
$location.url('/clinical-animations-detail');
},
function (error) {
// handle errors here
console.log(' $scope.AnimationData = ' + error.statusText);
}
);
}
}
$rootScope.openCABodyViewMain = function () {
if ($rootScope.isCallFromOtherModule) {
$scope.CAModuleData = ModuleService.getModuleData("CLINICAL_ANIMATIONS");
if($scope.CAModuleData.length<1) return;
$scope.DisableUI();
$scope.readyToLoad = true;
$rootScope.CAWindowLoadComplete = false;
$scope.wincount = 1;
var winlen = $scope.CAModuleData.length;
var timeint = null;
timeint = $interval(function () {
if ($scope.readyToLoad == true) {
var windata = $scope.CAModuleData[$scope.wincount - 1];
$scope.openBodyView(windata);
}
$scope.readyToLoad = false;
if ($scope.wincount < winlen && $rootScope.CAWindowLoadComplete == true) {
$scope.wincount = $scope.wincount + 1;
$rootScope.CAWindowLoadComplete = false;
$scope.readyToLoad = true;
}
if ($scope.wincount == winlen && $rootScope.CAWindowLoadComplete == true) {
$scope.stopInterval();
$scope.$emit("LoadModuleComplete", "CLINICAL_ANIMATIONS");
}
}, 100);
$scope.stopInterval = function () {
if (angular.isDefined(timeint)) {
$interval.cancel(timeint);
timeint = undefined;
}
};
}
else {
$scope.DisableUI();
$scope.openBodyView(null);
}
}
$scope.openBodyView = function (caModuleData) {
if ($rootScope.isCallFromOtherModule == true) {
$scope.caOpenInOtherModules = caModuleData;
$rootScope.MULTI_VIEW_ID += 1;
var windowviewid = $rootScope.MULTI_VIEW_ID;
$scope.initializeCAWindowData(windowviewid, false, $scope.caOpenInOtherModules.currentWindowId);
var moduleName = $scope.caOpenInOtherModules.mType;
$scope.SetCAwindowStoreData(windowviewid, 'moduleName', moduleName);
var promise = DataService.getJson('~/../content/data/json/ca/ca_dat_contentlist_mp4link.json')
promise.then(
function (result) {
$scope.CAlistViewData = result.root.CAData;
// serial no of imageid
var imageId = $scope.caOpenInOtherModules.id;
var clickedCAVideoData = [];
clickedCAVideoData = new jinqJs()
.from($scope.CAlistViewData)
.where('_id == ' + imageId)
.select('_Video', '_LowerSummary', '_HostedFolderId');
if (clickedCAVideoData.length == 0)
{
$rootScope.CAWindowLoadComplete = true
return;
}
$scope.SetCAwindowStoreData(windowviewid, 'imageId', imageId);
var clickedCAVideo = clickedCAVideoData[0]._Video;
var clickedCASummary = clickedCAVideoData[0]._LowerSummary;
var hostedFolderId = clickedCAVideoData[0]._HostedFolderId;
$scope.SetCAwindowStoreData(windowviewid, 'clickedCAVideo', clickedCAVideo);
$scope.SetCAwindowStoreData(windowviewid, 'clickedCASummary', clickedCASummary);
$scope.SetCAwindowStoreData(windowviewid, 'hostedFolderId', hostedFolderId);
var isTextVisible = $scope.caOpenInOtherModules.textVisible;
$scope.SetCAwindowStoreData(windowviewid, 'isTextVisible', isTextVisible);
var ciTitle = $scope.caOpenInOtherModules.anatomyTitle;
$scope.SetCAwindowStoreData(windowviewid, 'currentViewTitle', ciTitle);
localStorage.setItem("currentViewTitle", ciTitle);
var isMaximize = $scope.caOpenInOtherModules.maximised!=undefined?$scope.caOpenInOtherModules.maximised:false;
var isMinimize = $scope.caOpenInOtherModules.minimised!=undefined?$scope.caOpenInOtherModules.minimised:false;
$scope.SetCAwindowStoreData(windowviewid, 'maximised', isMaximize);
$scope.SetCAwindowStoreData(windowviewid, 'minimised', isMinimize);
if($location.url()== "/curriculum-builder-detail") {
$scope.SetCAwindowStoreData(windowviewid,'parentSlugName',($location.url()).replace('/', ''));
}
else
{
$scope.SetCAwindowStoreData(windowviewid,'parentSlugName','clinical-animations');
}
$scope.loadCAAnimation(windowviewid);
},
function (error) {
// handle errors here
console.log(' $scope.CAllustrationData = ' + error.statusText);
}
);
}
else {
$scope.SetCAwindowStoreData($rootScope.MULTI_VIEW_ID, 'parentSlugName', 'clinical-animations');
$scope.loadCAAnimation($rootScope.MULTI_VIEW_ID);
}
}
$scope.loadCAAnimation = function (windowviewid) {
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
$scope.DisableUI();
// $scope.jsPanelID = 'caVideoPanel' + '_' + windowviewid;
//changes to find the id by partail match
$scope.jsPanelID = 'caImagePanel' + '_' + windowviewid;
var clickedCAVideo = $scope.GetCAwindowStoreData(windowviewid, 'clickedCAVideo');
var clickedCASummary = $scope.GetCAwindowStoreData(windowviewid, 'clickedCASummary');
var hostedFolderId = $scope.GetCAwindowStoreData(windowviewid, 'hostedFolderId');
var tittle = $scope.GetCAwindowStoreData(windowviewid, 'currentViewTitle');
var poster = $scope.hostedServer + hostedFolderId + "/" + hostedFolderId + ".jpg";
var admp4 = $scope.hostedServer + hostedFolderId + "/" + hostedFolderId + "_ad.mp4";
var hdvideo = $scope.hostedServer + hostedFolderId + "/" + hostedFolderId + "_HD.mp4";
var webm = $scope.hostedServer + hostedFolderId + "/" + hostedFolderId + ".webm";
var ogv = $scope.hostedServer + hostedFolderId + "/" + hostedFolderId + ".ogv";
var playerScript = "~/../libs/video_4_12_11/video_4_12_11.js";
var vtt = "~/../content/data/vtt/" + hostedFolderId + ".vtt";
if ($rootScope.isCallFromOtherModule) {
if($rootScope.linkToOpenCa==true)
{
$scope.jsPanelWidth = $(window).outerWidth()-30;
$scope.jsPanelHeight = $(window).outerHeight() - 105;
$scope.jsPanelLeft = 1;
$scope.jsPanelTop = 55;
}
else
{
// open JS panel for curriculum with define cornonate in CB jason
$scope.jsPanelWidth = $scope.caOpenInOtherModules.size.width;//1000;
if ($scope.caOpenInOtherModules.size.width < 900)
$scope.jsPanelWidth = 900;
$scope.jsPanelHeight = $scope.caOpenInOtherModules.size.height;
if ($scope.caOpenInOtherModules.size.height < 510)
$scope.jsPanelHeight = 510;
$scope.jsPanelLeft = $scope.caOpenInOtherModules.position.x;
if ($scope.caOpenInOtherModules.position.x <= 1)
$scope.jsPanelLeft = 0;
$scope.jsPanelTop = $scope.caOpenInOtherModules.position.y;
if ($scope.caOpenInOtherModules.position.y < 30)
$scope.jsPanelTop = 30;
if($location.url()!= "/curriculum-builder-detail") {
$scope.jsPanelLeft = 1;
$scope.jsPanelTop = 85;
}
}
}
else {
$scope.jsPanelWidth = $(window).outerWidth()-30;
$scope.jsPanelHeight = $(window).outerHeight() - 105;
$scope.jsPanelLeft = 1;
$scope.jsPanelTop = 55;
}
if (clickedCAVideo.length > 0 && clickedCASummary.length > 0) {
if($rootScope.linkToOpenCa==true)
{
$scope.jsPanelCA = $.jsPanel({
id: $scope.jsPanelID,
selector: '.caView',
theme: 'success',
currentController: 'CAController',
parentSlug: $scope.GetCAwindowStoreData(windowviewid, 'parentSlugName'),
content: '' +
'' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ',
title: tittle,
position: {
top: $scope.jsPanelTop,
left: $scope.jsPanelLeft
},
size: {
width: $scope.jsPanelWidth,
height: $scope.jsPanelHeight
},
onmaximized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetCAwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetCAwindowStoreData(windowviewid, 'maximised',true);
$scope.SetCAwindowStoreData(windowviewid, 'minimised',false);
var canvasDIvHeight = $('#caImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
$rootScope.resetMenuOptionOnClick(pnlName);
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
var aodheight = screen.height;
if(aodheight>=1024)
{
$("#caImagePanel_"+windowviewid).css('height',canvasDIvHeight+30-150);
$('#caImagePanel_' + windowviewid+ " .jsPanel-content").css('height',canvasDIvHeight-150);
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-150-120 );
}
else if(aodheight<1024)
{
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
}
}
},
draggable: "disabled",
resizable: "disabled",
controls: { buttons: 'none' }
});
}
else
{
$scope.jsPanelCA = $.jsPanel({
id: $scope.jsPanelID,
selector: '.caView',
theme: 'success',
currentController: 'CAController',
parentSlug: $scope.GetCAwindowStoreData(windowviewid, 'parentSlugName'),
content: '' +
'' +
' ' +
' ' +
' ' +
' ' +
' ' +
' ',
title: tittle,
position: {
top: $scope.jsPanelTop,
left: $scope.jsPanelLeft
},
size: {
width: $scope.jsPanelWidth,
height: $scope.jsPanelHeight
},
onminimized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetCAwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetCAwindowStoreData(windowviewid, 'minimised',true);
$scope.SetCAwindowStoreData(windowviewid, 'maximised',false);
},
onmaximized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetCAwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetCAwindowStoreData(windowviewid, 'maximised',true);
$scope.SetCAwindowStoreData(windowviewid, 'minimised',false);
var canvasDIvHeight = $('#caImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
$rootScope.resetMenuOptionOnClick(pnlName);
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
var aodheight = screen.height;
if(aodheight>=1024)
{
$("#caImagePanel_"+windowviewid).css('height',canvasDIvHeight+30-150);
$('#caImagePanel_' + windowviewid+ " .jsPanel-content").css('height',canvasDIvHeight-150);
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-150-120 );
}
else if(aodheight<1024)
{
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
}
}
},
onnormalized:function (panel) {
var pnlName=panel[0].id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var isAutoCalled = $scope.GetCAwindowStoreData(windowviewid, 'minmaxAutoEvent');
if(!isAutoCalled)
{
$rootScope.UnsaveCurriculum = true;
}
$scope.SetCAwindowStoreData(windowviewid, 'minimised',false);
$scope.SetCAwindowStoreData(windowviewid, 'maximised',false);
var canvasDIvHeight = $('#caImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
$rootScope.resetMenuOptionOnClick(pnlName);
},
resizable: {
minWidth: 600,
minHeight: 500,
stop: function (event, ui) {
var pnlName=event.currentTarget.id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
var canvasDIvHeight = $('#caImagePanel_' + windowviewid+ " .jsPanel-content").height();
$scope.SetCAwindowStoreData(windowviewid, 'width', ui.size.width);
$scope.SetCAwindowStoreData(windowviewid, 'height', canvasDIvHeight);
$scope.SetCAwindowStoreData(windowviewid, 'y', ui.position.top);
$scope.SetCAwindowStoreData(windowviewid, 'x', ui.position.left);
$rootScope.UnsaveCurriculum = true;
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
$rootScope.resetMenuOptionOnClick(pnlName);
}
},
draggable: {
stop: function( event, ui ) {
var pnlName=event.currentTarget.id;
var len = (pnlName).split("_").length;
var windowviewid = (pnlName).split("_")[len - 1];
$scope.SetCAwindowStoreData(windowviewid, 'y', ui.position.top);
$scope.SetCAwindowStoreData(windowviewid, 'x', ui.position.left);
$rootScope.UnsaveCurriculum = true;
$rootScope.resetMenuOptionOnClick(pnlName);
}
}
});
}
var isMaximize = $scope.GetCAwindowStoreData(windowviewid, 'maximised');
var isMinimize = $scope.GetCAwindowStoreData(windowviewid, 'minimised');
if (isMaximize) {
$scope.jsPanelCA.maximize();
}
else if (isMinimize) {
$scope.jsPanelCA.minimize();
}
else {
$scope.jsPanelCA.normalize();
}
$rootScope.AllPanelObject(windowviewid,$scope.jsPanelCA);
$("#caImagePanel_"+windowviewid).css('overflow','hidden');
// set false after initial call of min,max or normal
$scope.SetCAwindowStoreData(windowviewid, 'minmaxAutoEvent', false);
$scope.SetCAwindowStoreData(windowviewid, 'y', $scope.jsPanelTop);
$scope.SetCAwindowStoreData(windowviewid, 'x', $scope.jsPanelLeft);
$scope.SetCAwindowStoreData(windowviewid, 'width', $scope.jsPanelWidth);
$scope.SetCAwindowStoreData(windowviewid, 'height', $scope.jsPanelHeight);
$scope.SetCAwindowStoreData(windowviewid, 'currentSlug', 'clinical-animations-detail');
$('html, body').animate({ scrollTop: 0 });
$rootScope.openViews.push(
{
"module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
"slug": $scope.GetCAwindowStoreData(windowviewid, 'currentSlug')
});
var canvasDIvHeight = $('#caImagePanel_' + windowviewid+ " .jsPanel-content").height();
$('#playerinlineVideo_'+ windowviewid ).css("height",canvasDIvHeight-120 );
var videoHeight = $('#playerinlineVideo_'+ windowviewid ).height();
var textH = $('.video-subtitle').height();
textH = textH + 40;
var blackBorderHeight = canvasDIvHeight - (videoHeight + textH);
if ($('.jsPanel-content').length > 0) {
$('.video-subtitle').css('margin-bottom', blackBorderHeight);
$('#divplayerinlineVideo_'+ windowviewid ).css('background', '#fff');
//Android > Clinical Animations > The animation does not fit to the screen in the Landscape mode.
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { $('.jsPanel-content').css("width", "100%"); }
}
if(screen.height<=640)
{
$('#btnTxtOnOff_' + windowviewid).css("top", "-15px");
}
}
//Calling methode for save Js Panel Activity for SaveCB
$scope.PanelActivity();
}
$scope.videoOnLoad = function (windowviewid)
{
$scope.EnableUI();
if ($rootScope.isCallFromOtherModule) {
//$scope.JsPanelclick(windowviewid);
$rootScope.CAWindowLoadComplete = true;
}
$scope.JsPanelclick(windowviewid);
var isTextVisible = $scope.GetCAwindowStoreData(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");
}
}
$scope.JsPanelclick = function (windowviewid) {
//reset option list manager and annotation
//call when module loaded
$rootScope.resetMenuOption();
// call from while open module in CB
//remove pre event
// $("#caImagePanel_" + windowviewid).off("click");
$("#caImagePanel_" + windowviewid).on('click', function (event) {
//after drawing annotation click not work on iPad/Android device
var pnlName = event.currentTarget.id;
$rootScope.resetMenuOptionOnClick(pnlName);
});
}
$scope.loadCAPlayer = function (summary, link, vidNumber) {
$scope.clickedCASummary = summary;
$scope.clickedCAVideo = link;
$scope.videoNumber = vidNumber;
};
$scope.ReloadListViewImageDiv = function (id, windowviewid) {
//console.log(id);
$scope.idSelected = id;
$scope.hiderow = true;
var AnimationData = $scope.GetCAwindowStoreData(windowviewid, 'AnimationData');
var SelectedCAthumbImage = [];
SelectedCAthumbImage = new jinqJs()
.from(AnimationData)
.where('_id = ' + id)
.select('_ThumbnailImage', '_Summary', '_id', '_Title');
$scope.SelectedCAthumbImage = "~/../content/images/ca/thumbnails/" + SelectedCAthumbImage[0]._ThumbnailImage;
$scope.SelectedCASummary = SelectedCAthumbImage[0]._Summary;
$scope.SelectedCAId = SelectedCAthumbImage[0]._id;
$scope.SelectedCATitle = SelectedCAthumbImage[0]._Title;
//Set the scroll position of the tablebody to show selected row.
var curCAListViewScroll = $rootScope.getLocalStorageValue("CAListViewScroll");
if (typeof (curCAListViewScroll) !== "undefined" && curCAListViewScroll !== null && curCAListViewScroll !== '') {
if (typeof InstallTrigger !== 'undefined') {
$('#ListViewDiv').animate({ scrollTop: $rootScope.getLocalStorageValue("CAListViewScroll") });
}
else {
$('#ListViewDiv').scrollTop($rootScope.getLocalStorageValue("CAListViewScroll"));
}
}
};
$scope.hideListViewDiv = function () {
if ($rootScope.getLocalStorageValue("currentCATabView") == 2) {
localStorage.setItem("CASelectedRowId", "");
if ($('.selected').hasClass("selected")) { $('.selected').removeClass("selected"); }
$scope.hiderow = false;
}
}
$scope.GetTextVisiblity = function (windowviewid, btnTextValue) {
var isVisible;
if (btnTextValue == "Text On") {
isVisible = false;
$scope.SetCAwindowStoreData(windowviewid, 'isTextVisible', isVisible);
} else {
isVisible = true;
$scope.SetCAwindowStoreData(windowviewid, 'isTextVisible', 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.CAWindowData.length; index++) {
if ($rootScope.CAWindowData[index].multiwinid == windowviewid) {
if (index != -1) {
// remove module which one is loaded
$rootScope.CAWindowData.splice(index, 1);
if ($('#' + panelid).html() != undefined) {
$('#' + panelid).remove();
}
// $rootScope.resetjsPanelTop(panelid);
}
}
}
}
//Created method by Sandeep for Save JSPanel Activity on the CB module
$scope.PanelActivity = function () {
// close panel
$(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);
});
}
}]);
function videoOnLoad(event) {
setTimeout(function()
{
var scope = angular.element(document.getElementById("CAView")).scope();
// var len = (event.target.id).split("_").length;
var windowviewid = (event.target.id).split("_")[1];
scope.$apply(function () {
scope.videoOnLoad(windowviewid);
});
}, 500);
}
function GetTextVisibityCA(event) {
var scope = angular.element(document.getElementById("CAView")).scope();
var windowviewid = (event.target.id).split("_")[1];
var btnTextValue = event.target.innerText;
scope.$apply(function () {
scope.GetTextVisiblity(windowviewid, btnTextValue);
});
}
function copygridbtnclick(event)
{
var id = (event.target.id).split("_")[1];
function setTooltip(message) {
$('#spn_'+id).css({'visibility':'visible','margin-left':'0px','opacity':1});
$('#spn_'+id).text(message);
}
function hideTooltip() {
setTimeout(function() {
$('#spn_'+id).css({'visibility':'hidden','margin-left':'-50px','opacity':0});
$('#spn_'+id).text('');
}, 2000);
}
var clipboard = new ClipboardJS('#'+event.target.id);
clipboard.on('success', function(e) {
setTooltip('link copied!');
hideTooltip();
});
clipboard.on('error', function(e) {
setTooltip('link not copied!');
hideTooltip();
});
}
function copylistbtnclick(event)
{
var id = (event.target.id).split("_")[1];
function setTooltip(message) {
$('#spnlist_'+id).css({'visibility':'visible','opacity':1});
$('#spnlist_'+id).text(message);
}
function hideTooltip() {
setTimeout(function() {
$('#spnlist_'+id).css({'visibility':'hidden','opacity':0});
$('#spnlist_'+id).text('');
}, 2000);
}
var clipboard = new ClipboardJS('#'+event.target.id);
clipboard.on('success', function(e) {
setTooltip('link copied!');
hideTooltip();
});
clipboard.on('error', function(e) {
setTooltip('link not copied!');
hideTooltip();
});
}