'use strict'; AIA.controller("MyAnimationController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "ModuleService", "$interval", "AIAConstants", function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout, ModuleService, $interval, AIAConstants) { $scope.ObjectAttribute=function(windowviewid) { var windata={ 'multiwinid': windowviewid, 'videoSource': "", 'moduleName': '', 'currentViewTitle': '', 'parentSlugName': '', 'currentSlug': '', 'imageId': '', 'y': 0, 'x': 0, 'width': 0, 'height': 0, 'minimised': false, 'maximised': false, 'minmaxAutoEvent':true, 'isSourceExist':true }; return windata; } $scope.initializeVideoWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) { if (isOpenWithExistsModule || openPanelNo == 0) { if ($rootScope.VideoWindowData != undefined) { $rootScope.VideoWindowData.length = 0; } else { $rootScope.VideoWindowData = []; } $rootScope.VideoWindowData.push($scope.ObjectAttribute(windowviewid)); } else { var isNewWindow = true; for (var k = 0; k < $rootScope.VideoWindowData.length; k++) { if ($rootScope.VideoWindowData[k].multiwinid == windowviewid) { isNewWindow = false; break; } } if (isNewWindow) { $rootScope.VideoWindowData.push($scope.ObjectAttribute(windowviewid)); } } } $scope.GetVideowindowStoreData = function (windowviewid, keyname) { for (var x = 0 ; x < $rootScope.VideoWindowData.length; x++) { if ($rootScope.VideoWindowData[x].multiwinid == windowviewid) { return $rootScope.VideoWindowData[x][keyname]; } } } $scope.SetVideowindowStoreData = function (windowviewid, keyname, value) { for (var x = 0 ; x < $rootScope.VideoWindowData.length; x++) { if ($rootScope.VideoWindowData[x].multiwinid == windowviewid) { $rootScope.VideoWindowData[x][keyname] = value; } } } // access from home controller $rootScope.SetVideowindowData=function(windowviewid,keyname,data) { for(var x=0 ;x < $rootScope.VideoWindowData.length;x++){ if($rootScope.VideoWindowData[x].multiwinid==windowviewid) { $rootScope.VideoWindowData[x][keyname]=data; } } } $scope.DisableVideoUI = function (windowviewid) { var modulePanel = $("#vidImagePanel_"+windowviewid).find(" .jsPanel-content"); if(modulePanel.length>0) { modulePanel[0].style.pointerEvents="none"; modulePanel[0].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.EnableVideoUI = function (windowviewid) { var modulePanel = $("#vidImagePanel_"+windowviewid).find(" .jsPanel-content"); if(modulePanel.length>0) { modulePanel[0].style.pointerEvents="auto"; modulePanel[0].style.opacity="1"; } $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); // CB module enable all $('#HomeContainerDiv').css('pointer-events', 'auto'); $('#HomeContainerDiv').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.VideoWindowData.length; index++) { if ($rootScope.VideoWindowData[index].multiwinid == windowviewid) { if (index != -1) { // remove module which one is loaded var reffid=$rootScope.VideoWindowData[index].imageId; $rootScope.VideoWindowData.splice(index, 1); //remove also stream/source video from close panel from cb if($rootScope.collectAnimationSource !=undefined) { for (var vdx = 0 ; vdx < $rootScope.collectAnimationSource.length; vdx++) { if(reffid==$rootScope.collectAnimationSource[vdx].imageId) $rootScope.collectAnimationSource.splice(vdx, 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.OpenMyAnimationViewMain = function () { if ($rootScope.isCallFromOtherModule) { $scope.VideoModuleData = ModuleService.getModuleData("MY_ANIMATIONS"); if($scope.VideoModuleData.length<1) return; $scope.readyToLoad = true; $rootScope.VideoLoadComplete = false; $scope.wincount = 1; var winlen = $scope.VideoModuleData.length; var timeint = null; timeint = $interval(function () { if ($scope.readyToLoad == true) { var windata = $scope.VideoModuleData[$scope.wincount - 1]; $scope.OpenAnimationView(windata); } $scope.readyToLoad = false; if ($scope.wincount < winlen && $rootScope.VideoLoadComplete == true) { $scope.wincount = $scope.wincount + 1; $rootScope.VideoLoadComplete = false; $scope.readyToLoad = true; } if ($scope.wincount == winlen && $rootScope.VideoLoadComplete == true) { $scope.stopInterval(); $scope.$emit("LoadModuleComplete", "MY_ANIMATIONS"); } }, 100); $scope.stopInterval = function () { if (angular.isDefined(timeint)) { $interval.cancel(timeint); timeint = undefined; } }; } } $scope.OpenAnimationView = function (vidModuleData) { $scope.VidOpenInOtherModules = vidModuleData; $rootScope.MULTI_VIEW_ID += 1; var windowviewid = $rootScope.MULTI_VIEW_ID; $scope.DisableVideoUI(windowviewid); $scope.initializeVideoWindowData(windowviewid, false, $scope.VidOpenInOtherModules.currentWindowId); var moduleName = $scope.VidOpenInOtherModules.mType; $scope.SetVideowindowStoreData(windowviewid, 'moduleName', moduleName); // serial no of imageid var imageId = $scope.VidOpenInOtherModules.id; $scope.SetVideowindowStoreData(windowviewid, 'imageId', imageId); var videoSource=$scope.VidOpenInOtherModules.videoSource; $scope.SetVideowindowStoreData(windowviewid, 'videoSource', videoSource); if(videoSource=="" ||videoSource==undefined) { $scope.SetVideowindowStoreData(windowviewid, 'isSourceExist', false); } var aiTitle = $scope.VidOpenInOtherModules.anatomyTitle; $scope.SetVideowindowStoreData(windowviewid, 'currentViewTitle', aiTitle); localStorage.setItem("currentViewTitle", aiTitle); var isMaximize = $scope.VidOpenInOtherModules.maximised!=undefined?$scope.VidOpenInOtherModules.maximised:false; var isMinimize = $scope.VidOpenInOtherModules.minimised!=undefined?$scope.VidOpenInOtherModules.minimised:false; $scope.SetVideowindowStoreData(windowviewid, 'maximised', isMaximize); $scope.SetVideowindowStoreData(windowviewid, 'minimised', isMinimize); if($location.url()== "/curriculum-builder-detail") { $scope.SetVideowindowStoreData(windowviewid,'parentSlugName',($location.url()).replace('/', '')); } else { $scope.SetVideowindowStoreData(windowviewid,'parentSlugName','');//back to home screen } $scope.loadMyAnimation(windowviewid); } $scope.loadMyAnimation = function (windowviewid) { $scope.jsPanelID = 'vidImagePanel' + '_' + windowviewid; var tittle = $scope.GetVideowindowStoreData(windowviewid, 'currentViewTitle'); var animationSource = $scope.GetVideowindowStoreData(windowviewid, 'videoSource'); var isSourceExist = $scope.GetVideowindowStoreData(windowviewid, 'isSourceExist'); if(isSourceExist==true) { // get animation from uploaded stream if (animationSource.indexOf('base64') == -1) { animationSource="data:video/mp4;base64,"+animationSource; } } else { // get animation from server animationSource=$scope.aiaAnimationPath+ tittle + ".mp4"; } var playerScript = "~/../libs/video_4_12_11/video_4_12_11.js"; // open JS panel for curriculum with define cornonate in CB jason $scope.jsPanelWidth = $scope.VidOpenInOtherModules.size.width;//1000; if ($scope.VidOpenInOtherModules.size.width < 500) $scope.jsPanelWidth = 500; $scope.jsPanelHeight = $scope.VidOpenInOtherModules.size.height; if ($scope.VidOpenInOtherModules.size.height < 400) $scope.jsPanelHeight = 400; $scope.jsPanelLeft = $scope.VidOpenInOtherModules.position.x; if ($scope.VidOpenInOtherModules.position.x <= 1) $scope.jsPanelLeft = 0; $scope.jsPanelTop = $scope.VidOpenInOtherModules.position.y; if ($scope.VidOpenInOtherModules.position.y < 30) $scope.jsPanelTop = 30; if($location.url()!= "/curriculum-builder-detail") { $scope.jsPanelLeft = 1; $scope.jsPanelTop = 85; } if (animationSource.length > 0 ) { $scope.jsPanelVideo = $.jsPanel({ id: $scope.jsPanelID, selector: '.videoView', theme: 'success', currentController: 'MyAnimationController', parentSlug: $scope.GetVideowindowStoreData(windowviewid, 'parentSlugName'), content: '' + '