'use strict'; AIA.controller("MyPictureController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout","ModuleService", "$interval", function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, ModuleService, $interval) { $scope.ObjectAttribute=function(windowviewid) { var windata={ 'multiwinid': windowviewid, 'imageSource': [], 'moduleName': '', 'currentViewTitle': '', 'parentSlugName': '', 'currentSlug': '', 'imageId': '', 'y': 0, 'x': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': false, 'minmaxAutoEvent':true, 'annotationData':{shapeStates:[],paintCanvasState:[]}, }; return windata; } $scope.initializePICWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) { if (isOpenWithExistsModule || openPanelNo == 0) { if ($rootScope.PICWindowData != undefined) { $rootScope.PICWindowData.length = 0; } else { $rootScope.PICWindowData = []; } $rootScope.PICWindowData.push($scope.ObjectAttribute(windowviewid)); } else { var isNewWindow = true; for (var k = 0; k < $rootScope.PICWindowData.length; k++) { if ($rootScope.PICWindowData[k].multiwinid == windowviewid) { isNewWindow = false; break; } } if (isNewWindow) { $rootScope.PICWindowData.push($scope.ObjectAttribute(windowviewid)); } } } $scope.GetPICwindowStoreData = function (windowviewid, keyname) { for (var x = 0 ; x < $rootScope.PICWindowData.length; x++) { if ($rootScope.PICWindowData[x].multiwinid == windowviewid) { return $rootScope.PICWindowData[x][keyname]; } } } $scope.SetPICwindowStoreData = function (windowviewid, keyname, value) { for (var x = 0 ; x < $rootScope.PICWindowData.length; x++) { if ($rootScope.PICWindowData[x].multiwinid == windowviewid) { $rootScope.PICWindowData[x][keyname] = value; } } } // access from home controller $rootScope.GetPICwindowData=function(windowviewid,keyname) { for(var x=0 ;x < $rootScope.PICWindowData.length;x++){ if($rootScope.PICWindowData[x].multiwinid==windowviewid) { return $rootScope.PICWindowData[x][keyname]; } } } // access from home controller $rootScope.SetPICwindowData=function(windowviewid,keyname,data) { for(var x=0 ;x < $rootScope.PICWindowData.length;x++){ if($rootScope.PICWindowData[x].multiwinid==windowviewid) { $rootScope.PICWindowData[x][keyname]=data; } } } $scope.DisableUI = function () { var myImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < myImagePanelConetent.length; i++) { myImagePanelConetent[i].style.pointerEvents = "none"; myImagePanelConetent[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 myImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < myImagePanelConetent.length; i++) { myImagePanelConetent[i].style.pointerEvents = "auto"; myImagePanelConetent[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.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.PICWindowData.length; index++) { if ($rootScope.PICWindowData[index].multiwinid == windowviewid) { if (index != -1) { // remove module which one is loaded $rootScope.PICWindowData.splice(index, 1); if ($('#' + panelid).html() != undefined) { $('#' + panelid).remove(); } // $rootScope.resetjsPanelTop(panelid); } } } } $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); }); } $rootScope.OpenMyPictureViewMain = function () { if ($rootScope.isCallFromOtherModule) { $scope.PicModuleData = ModuleService.getModuleData("MY_PICTURES"); if($scope.PicModuleData.length<1) return; $scope.DisableUI(); $scope.readyToLoad = true; $rootScope.PicLoadComplete = false; $scope.wincount = 1; var winlen = $scope.PicModuleData.length; var timeint = null; timeint = $interval(function () { if ($scope.readyToLoad == true) { var windata = $scope.PicModuleData[$scope.wincount - 1]; $scope.OpenPictureView(windata); } $scope.readyToLoad = false; if ($scope.wincount < winlen && $rootScope.PicLoadComplete == true) { $scope.wincount = $scope.wincount + 1; $rootScope.PicLoadComplete = false; $scope.readyToLoad = true; } if ($scope.wincount == winlen && $rootScope.PicLoadComplete == true) { $scope.stopInterval(); $scope.$emit("LoadModuleComplete", "MY_PICTURES"); } }, 100); $scope.stopInterval = function () { if (angular.isDefined(timeint)) { $interval.cancel(timeint); timeint = undefined; } }; } } $scope.OpenPictureView = function (picModuleData) { $scope.picOpenInOtherModules = picModuleData; $rootScope.MULTI_VIEW_ID += 1; var windowviewid = $rootScope.MULTI_VIEW_ID; $scope.initializePICWindowData(windowviewid, false, $scope.picOpenInOtherModules.currentWindowId); var moduleName = $scope.picOpenInOtherModules.mType; $scope.SetPICwindowStoreData(windowviewid, 'moduleName', moduleName); // serial no of imageid var imageId = $scope.picOpenInOtherModules.id; $scope.SetPICwindowStoreData(windowviewid, 'imageId', imageId); var imageSource=$scope.picOpenInOtherModules.imageSource; $scope.SetPICwindowStoreData(windowviewid, 'imageSource', imageSource); var aiTitle = $scope.picOpenInOtherModules.anatomyTitle; $scope.SetPICwindowStoreData(windowviewid, 'currentViewTitle', aiTitle); localStorage.setItem("currentViewTitle", aiTitle); var isMaximize = $scope.picOpenInOtherModules.maximised!=undefined?$scope.picOpenInOtherModules.maximised:false; var isMinimize = $scope.picOpenInOtherModules.minimised!=undefined?$scope.picOpenInOtherModules.minimised:false; $scope.SetPICwindowStoreData(windowviewid, 'maximised', isMaximize); $scope.SetPICwindowStoreData(windowviewid, 'minimised', isMinimize); // store image for export $rootScope.StoreTitleName(aiTitle); $rootScope.StoreOrgImageName(aiTitle); if($location.url()== "/curriculum-builder-detail") { $scope.SetPICwindowStoreData(windowviewid,'parentSlugName',($location.url()).replace('/', '')); } else { $scope.SetPICwindowStoreData(windowviewid,'parentSlugName','');//back to home screen } $scope.loadMyPicture(windowviewid); } $scope.loadMyPicture = function (windowviewid) { $scope.jsPanelID = 'picImagePanel' + '_' + windowviewid; var selectedpicture = $scope.GetPICwindowStoreData(windowviewid, 'imageSource'); if (selectedpicture.indexOf('base64') == -1) { selectedpicture="data:image/png;base64,"+selectedpicture; } var tittle = $scope.GetPICwindowStoreData(windowviewid, 'currentViewTitle'); // open JS panel for curriculum with define cornonate in CB jason $scope.jsPanelWidth = $scope.picOpenInOtherModules.size.width;//1000; $scope.jsPanelHeight = $scope.picOpenInOtherModules.size.height; if ($scope.picOpenInOtherModules.size.height < 540) $scope.jsPanelHeight = 540; $scope.jsPanelLeft = $scope.picOpenInOtherModules.position.x; if ($scope.picOpenInOtherModules.position.x <= 1) $scope.jsPanelLeft = 0; $scope.jsPanelTop = $scope.picOpenInOtherModules.position.y; if ($scope.picOpenInOtherModules.position.y < 30) $scope.jsPanelTop = 30; if($location.url()!= "/curriculum-builder-detail") { $scope.jsPanelLeft = 1; $scope.jsPanelTop = 85; } $scope.jsPanelPIC = $.jsPanel({ id: $scope.jsPanelID, selector: '.picView', theme: 'success', currentController: 'MyPictureController', parentSlug: $scope.GetPICwindowStoreData(windowviewid, 'parentSlugName'), content: '