AIA.controller("3dAController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile", "$timeout", "ModuleService", "$interval", function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile, $timeout, ModuleService, $interval) { // $scope.threeDAnatomyData; $scope.initialize3DWindowData = function (windowviewid, isOpenWithExistsModule, cbwindowid) { if (isOpenWithExistsModule || cbwindowid == 0) { if ($rootScope.TheeDWindowData != undefined) { $rootScope.TheeDWindowData.length = 0; } else { $rootScope.TheeDWindowData = []; } $rootScope.TheeDWindowData.push( { 'multiwinid': windowviewid, 'threeDAnatomyData': [], 'searchCAListViewData': [], 'ImagePath': '', 'moduleName': '', 'currentViewTitle': '', 'parentSlugName': '', 'currentSlug': '', 'imageId': '', 'imageName': '', 'clickedCAVideo': '', 'clickedCASummary': '', 'hostedFolderId': '', 'isTextVisible': true }); } else { var isNewWindow = true; for (var k = 0; k < $rootScope.TheeDWindowData.length; k++) { if ($rootScope.TheeDWindowData[k].multiwinid == windowviewid) { isNewWindow = false; break; } } if (isNewWindow) { $rootScope.TheeDWindowData.push( { 'multiwinid': windowviewid, 'threeDAnatomyData': [], 'searchCAListViewData': [], 'ImagePath': '', 'moduleName': '', 'currentViewTitle': '', 'parentSlugName': '', 'currentSlug': '', 'imageId': '', 'imageName': '', 'clickedCAVideo': '', 'clickedCASummary': '', 'hostedFolderId': '', 'isTextVisible': true }); } } } $scope.Get3DwindowStoreData = function (windowviewid, keyname) { for (var x = 0 ; x < $rootScope.TheeDWindowData.length; x++) { if ($rootScope.TheeDWindowData[x].multiwinid == windowviewid) { return $rootScope.TheeDWindowData[x][keyname]; } } } $scope.Set3DwindowStoreData = function (windowviewid, keyname, value) { for (var x = 0 ; x < $rootScope.TheeDWindowData.length; x++) { if ($rootScope.TheeDWindowData[x].multiwinid == windowviewid) { $rootScope.TheeDWindowData[x][keyname] = value; } } } $rootScope.Get3DWindowId = function () { // handle for single window if ($rootScope.TheeDWindowData.length > 0) { for (var x = 0 ; x < $rootScope.TheeDWindowData.length; x++) { return $rootScope.TheeDWindowData[x].multiwinid; } } else return 0; } $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 $('#CBDetailPageDiv').css('pointer-events', 'none'); $('#CBDetailPageDiv').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 $('#CBDetailPageDiv').css('pointer-events', 'auto'); $('#CBDetailPageDiv').css('opacity', '1'); } $scope.loadAIModuleById = function (moduleId) { $rootScope.isCallFromOtherModule = undefined; $rootScope.MULTI_VIEW_ID += 1 $scope.initialize3DWindowData($rootScope.MULTI_VIEW_ID, true, undefined); $scope.DisableUI(); if ($rootScope.refreshcheck == null) { $location.path('/'); } var currentURL = $location.path(); var selectedModuleName = ''; //set module title angular.forEach($rootScope.userModules, function (value, key) { // if (value.slug === currentURL.replace('/', '')) { if (value.slug === "3d-anatomy-list") { selectedModuleName = value.name; } $rootScope.currentActiveModuleTitle = selectedModuleName; }) $scope.Set3DwindowStoreData($rootScope.MULTI_VIEW_ID, 'moduleName', "3D Anatomy"); $scope.Load3DJsonData($rootScope.MULTI_VIEW_ID); $scope.scroll(); }; $scope.scroll = function () { $("html,body").scrollTop(0); } $scope.Load3DJsonData = function (windowviewid) { var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json') promise.then( function (result) { var threeDAnatomyData = new jinqJs() .from(result.root.ThreeDAData) .orderBy([{ field: '_Title', sort: 'asc' }]) .select(); $scope.Set3DwindowStoreData(windowviewid, 'threeDAnatomyData', threeDAnatomyData); // console.log($scope.selectedCIListViewData); $('#grid-view').empty(); angular.forEach(threeDAnatomyData, function (value, key) { $scope.imagePath = "~/../content/images/3da/thumbnails/" + value._ThumbnailImage; var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); }); $timeout(function () { $scope.EnableUI(); }, 200); }, function (error) { $scope.EnableUI(); // handle errors here console.log(' $scope.threeDAnatomyData = ' + error.statusText); } ); }; $scope.Open3DModel = function ($event) { $rootScope.currentBodyViewId = $event.currentTarget.id; var windowviewid = $rootScope.MULTI_VIEW_ID; var selectedThreeDAdata = $scope.Get3DwindowStoreData(windowviewid, 'threeDAnatomyData'); if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") { var ThreeDTitle = []; ThreeDTitle = new jinqJs() .from(selectedThreeDAdata) .where('_id = ' + $event.currentTarget.id) .select('_Title', '_3dimagepath'); $rootScope.ViewTitle = ThreeDTitle[0]._Title; } else { $rootScope.ViewTitle = $event.currentTarget.textContent; } localStorage.setItem("currentViewTitleFromJson", $rootScope.ViewTitle); localStorage.setItem("currentBodyViewId", $event.currentTarget.id); var ImagePath = ThreeDTitle[0]._3dimagepath; $scope.Set3DwindowStoreData(windowviewid, 'currentViewTitle', $rootScope.ViewTitle); $scope.Set3DwindowStoreData(windowviewid, 'imageId', $event.currentTarget.id); $scope.Set3DwindowStoreData(windowviewid, 'ImagePath', ImagePath); var u = $location.url(); $location.url('/3d-anatomy-details'); } $scope.Open3DModelBodyMain = function () { if ($rootScope.isCallFromOtherModule) { $scope.ThreeDModuleData = ModuleService.getModuleData("THREE_D_ANATOMY"); $scope.readyToLoad = true; $rootScope.ThreeDWindowLoadComplete = false; $scope.wincount = 1; var winlen = $scope.ThreeDModuleData.length; var timeint = null; var slideId = ""; timeint = $interval(function () { if ($scope.readyToLoad == true) { var windata = $scope.ThreeDModuleData[$scope.wincount - 1]; slideId = windata.slideId; $scope.Open3DModelBody(windata); } $scope.readyToLoad = false; if ($scope.wincount < winlen && $rootScope.ThreeDWindowLoadComplete == true) { $scope.wincount = $scope.wincount + 1; $rootScope.ThreeDWindowLoadComplete = false; $scope.readyToLoad = true; } if ($scope.wincount == winlen && $rootScope.ThreeDWindowLoadComplete == true) { $scope.stopInterval(); $scope.$emit("LoadModuleComplete", "THREE_D_ANATOMY", slideId); } }, 100); $scope.stopInterval = function () { if (angular.isDefined(timeint)) { $interval.cancel(timeint); timeint = undefined; } }; } else { $scope.Open3DModelBody(null); } } $scope.Open3DModelBody = function (ThreeDModuleData) { $scope.DisableUI(); if ($rootScope.isCallFromOtherModule == true) { $scope.ThreeDOpenInOtherModules = ThreeDModuleData; $rootScope.MULTI_VIEW_ID += 1; var windowviewid = $rootScope.MULTI_VIEW_ID; $scope.initialize3DWindowData(windowviewid, false, $scope.ThreeDOpenInOtherModules.currentWindowId); var moduleName = $scope.ThreeDOpenInOtherModules.mType; $scope.Set3DwindowStoreData(windowviewid, 'moduleName', moduleName); var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json'); promise.then( function (result) { var imageId = $scope.ThreeDOpenInOtherModules.id; var clicked3DViewData = []; clicked3DViewData = new jinqJs().from(result.root.ThreeDAData) .where('_id == ' + imageId) .select('_Title', '_3dimagepath'); if (clicked3DViewData.length == 0) { $rootScope.ThreeDWindowLoadComplete = true return; } $scope.Set3DwindowStoreData(windowviewid, 'imageId', imageId); var ImagePath = clicked3DViewData[0]._3dimagepath; $scope.Set3DwindowStoreData(windowviewid, 'ImagePath', ImagePath); var ThreeDTitle = $scope.ThreeDOpenInOtherModules.anatomyTitle; $scope.Set3DwindowStoreData(windowviewid, 'currentViewTitle', ThreeDTitle); localStorage.setItem("currentViewTitle", ThreeDTitle); $scope.Set3DwindowStoreData(windowviewid, 'parentSlugName', ($location.url()).replace('/', '')); $scope.load3DAnimation(windowviewid); }, function (error) { // handle errors here console.log(' $scope.CAllustrationData = ' + error.statusText); } ); } else { $scope.Set3DwindowStoreData($rootScope.MULTI_VIEW_ID, 'parentSlugName', '3d-anatomy-list'); $scope.load3DAnimation($rootScope.MULTI_VIEW_ID); } } $scope.load3DAnimation = function (windowviewid) { if ($rootScope.refreshcheck == null) { $location.path('/'); } $scope.jsPanelID = 'ThreeDImagePanel' + '_' + windowviewid; var Selected3DImagePath = $scope.Get3DwindowStoreData(windowviewid, 'ImagePath'); var tittle = $scope.Get3DwindowStoreData(windowviewid, 'currentViewTitle'); if ($rootScope.isCallFromOtherModule) { // open JS panel for curriculum with define cornonate in CB jason $scope.jsPanelWidth = $scope.ThreeDOpenInOtherModules.size.width;//1000; if ($scope.ThreeDOpenInOtherModules.size.width < 900) $scope.jsPanelWidth = 900; $scope.jsPanelHeight = $scope.ThreeDOpenInOtherModules.size.height; if ($scope.ThreeDOpenInOtherModules.size.height > 750) $scope.jsPanelHeight = 750; $scope.jsPanelLeft = 320; $scope.jsPanelTop = $rootScope.cBModulejsPanelTop(); } else { $scope.jsPanelWidth = $(window).outerWidth() - 23; $scope.jsPanelHeight = $(window).outerHeight() - 104; $scope.jsPanelLeft = 1; $scope.jsPanelTop = 70; } if (Selected3DImagePath.length > 0) { $.jsPanel({ id: $scope.jsPanelID, selector: '.threeDView', theme: 'success', currentController: '3dAController', parentSlug: $scope.Get3DwindowStoreData(windowviewid, 'parentSlugName'), content: '
' + '' + '
', title: tittle, position: { top: $scope.jsPanelTop, left: $scope.jsPanelLeft }, size: { width: $scope.jsPanelWidth, height: $scope.jsPanelHeight }, }); $rootScope.currentSlug = '3d-anatomy-details'; $scope.Set3DwindowStoreData(windowviewid, 'currentSlug', '3d-anatomy-details'); $rootScope.openViews.push( { "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, "slug": $scope.Get3DwindowStoreData(windowviewid, 'currentSlug') }); } if (!$rootScope.isCallFromOtherModule) { $('#ThreeDView').css("height", $(window).outerHeight()-10); $('#ThreeDView').css("width", $(window).outerWidth()-20); } } $scope.AnimationOnLoad = function (windowviewid) { $scope.EnableUI(); if ($rootScope.isCallFromOtherModule) { $scope.JsPanelMouseEnter(windowviewid); $rootScope.ThreeDWindowLoadComplete = true; } } $scope.JsPanelMouseEnter = function (windowviewid) { // call from while open module in CB //click event not work on object-tag document //so then add mouseenter $("#ThreeDImagePanel_" + windowviewid).unbind('mouseenter');// remove prev event $("#ThreeDImagePanel_" + windowviewid).on('mouseenter', function (event) { // var pnlName = event.currentTarget.id; //console.log('Mouse enter fired: ' + event.currentTarget.id); $scope.$emit("cBEnableDisableMenuOption", ""); }); } }]); function AnimationOnLoad(event) { console.log('animation loaded') var scope = angular.element(document.getElementById("ThreeDView")).scope(); // var len = (event.target.id).split("_").length; var windowviewid = (event.target.id).split("_")[1]; scope.$apply(function () { scope.AnimationOnLoad(windowviewid); }); }