'use strict'; AIA.controller("AODController", ["$scope", "$window", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout","DataService", "ModuleService", "$interval", "AuthenticationService", "AIAConstants", function ($scope, $window, $rootScope, $compile, $http, log, $location, $timeout,DataService, ModuleService, $interval,AuthenticationService, AIAConstants) { $scope.ObjectAttribute=function(windowviewid) { var windata={ 'multiwinid': windowviewid, 'AODAnimationData': [], 'moduleName': '', 'aodUrl':'AodHome/CoursePlayerAIA', 'courseId':'', 'uid':'2',//categoty id. courseid checked in category id 'requestType':'SCORMPackage', 'currentViewTitle': '', 'parentSlugName': '', 'currentSlug': '', }; return windata; } $scope.initializeAODWindowData = function (windowviewid, isOpenWithExistsModule, openPanelNo) { if (isOpenWithExistsModule || openPanelNo == 0) { if ($rootScope.AODWindowData != undefined) { $rootScope.AODWindowData.length = 0; } else { $rootScope.AODWindowData = []; } $rootScope.AODWindowData.push($scope.ObjectAttribute(windowviewid)); } else { var isNewWindow = true; for (var k = 0; k < $rootScope.AODWindowData.length; k++) { if ($rootScope.AODWindowData[k].multiwinid == windowviewid) { isNewWindow = false; break; } } if (isNewWindow) { $rootScope.AODWindowData.push($scope.ObjectAttribute(windowviewid)); } } } $scope.GetAODwindowStoreData = function (windowviewid, keyname) { for (var x = 0 ; x < $rootScope.AODWindowData.length; x++) { if ($rootScope.AODWindowData[x].multiwinid == windowviewid) { return $rootScope.AODWindowData[x][keyname]; } } } $scope.SetAODwindowStoreData = function (windowviewid, keyname, value) { for (var x = 0 ; x < $rootScope.AODWindowData.length; x++) { if ($rootScope.AODWindowData[x].multiwinid == windowviewid) { $rootScope.AODWindowData[x][keyname] = value; } } } $scope.DisableUI = function () { var aniImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < aniImagePanelConetent.length; i++) { aniImagePanelConetent[i].style.pointerEvents = "none"; aniImagePanelConetent[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 aniImagePanelConetent = document.getElementsByClassName("jsPanel-content"); for (var i = 0; i < aniImagePanelConetent.length; i++) { aniImagePanelConetent[i].style.pointerEvents = "auto"; aniImagePanelConetent[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.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.AODWindowData.length; index++) { if ($rootScope.AODWindowData[index].multiwinid == windowviewid) { if (index != -1) { // remove module which one is loaded $rootScope.AODWindowData.splice(index, 1); if ($('#' + panelid).html() != undefined) { $('#' + panelid).remove(); } } } } } $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); }); } $scope.loadAIModuleById = function (moduleId) { $rootScope.MULTI_VIEW_ID += 1 if($rootScope.AODWindowData!=undefined) { if($rootScope.AODWindowData.length>0) { for(var x=0 ;x < $rootScope.AODWindowData.length;x++){ var winid=$rootScope.AODWindowData[x].multiwinid; if ($('#aodImagePanel_' + winid).html() != undefined) { $('#aodImagePanel_' + winid).remove(); } } $rootScope.AODWindowData=[]; } } $scope.initializeAODWindowData($rootScope.MULTI_VIEW_ID, true, undefined); $scope.DisableUI(); if ($rootScope.refreshcheck == null) { $location.path('/'); } $rootScope.currentActiveModuleTitle = "ADAM ON DEMAND"; $scope.SetAODwindowStoreData($rootScope.MULTI_VIEW_ID, 'moduleName', "ADAM ON DEMAND"); $scope.LoadAODJsonData($rootScope.MULTI_VIEW_ID); }; $scope.LoadAODJsonData = function (windowviewid) { //LicenseId would be zero for admin and gernal admin //get this from DB AuthenticationService.GetAodCoursesList($rootScope.userData.LicenseId) .then( function (aodResult) { if(aodResult.length>0 && aodResult != AIAConstants.NO_COURSE_FOUND) { var AODAnimationData = new jinqJs() .from(aodResult) .orderBy([{ field: 'BodySystem', sort: 'asc' }]) .select(); $scope.SetAODwindowStoreData(windowviewid, 'AODAnimationData', AODAnimationData); $scope.loadAODList(windowviewid); } else { $('#errorMessage').text(AIAConstants.NO_COURSE_FOUND_MESSAGE); $("#messageModal").modal('show'); $scope.EnableUI(); } }, function (error) { $scope.EnableUI(); }) }; $scope.loadAODList = function (windowviewid) { var selectedAODListViewData = $scope.GetAODwindowStoreData(windowviewid, 'AODAnimationData'); $('#grid-view').empty(); angular.forEach(selectedAODListViewData, function (value, key) { var imagePath = "~/../content/images/aod/thumbnails/" + value.CourseId+'.jpg'; 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('AODGridViewScroll') !== null && $location.url() == "/ADAM-on-demand") { $('html, body').animate({ scrollTop: $rootScope.getLocalStorageValue('AODGridViewScroll') }, 'slow'); } }, 200); $timeout(function () { $scope.EnableUI(); $scope.ResetGridListLength(); }, 400); } $scope.ResetGridListLength=function() { var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) { if(screen.height<=768) { $('#grid-view').css({"height":"660","overflow":"scroll"}); } else if(screen.height<=1024) { $('#grid-view').css({"height":"910","overflow":"scroll"}); } else { $('#grid-view').css({"height":"1250","overflow":"scroll"}); } } else { $('#grid-view').css({"height":"830","overflow":"scroll"}); } } $scope.openView = function ($event) { var windowviewid = $rootScope.MULTI_VIEW_ID; $rootScope.MenuModuleName = "AOD"; $rootScope.currentBodyViewId = $event.currentTarget.id; if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") { var selectedAODListViewData = $scope.GetAODwindowStoreData(windowviewid, 'AODAnimationData'); var selectedTileData = []; selectedTileData = new jinqJs() .from(selectedAODListViewData) .where('CourseId = ' + $event.currentTarget.id) .select(); $rootScope.ViewTitle = selectedTileData[0].CourseName; } else { $rootScope.ViewTitle = $event.currentTarget.textContent; } localStorage.setItem("currentViewTitle", $rootScope.ViewTitle); localStorage.setItem("currentBodyViewId", $event.currentTarget.id); $scope.SetAODwindowStoreData(windowviewid, 'currentViewTitle', $rootScope.ViewTitle); $scope.SetAODwindowStoreData(windowviewid, 'courseId', $event.currentTarget.id); var AODGridViewScrollPosition = $($window).scrollTop(); localStorage.setItem('AODGridViewScroll', AODGridViewScrollPosition); $location.url('/AOD-view-detail'); } $scope.openAODBodyViewMain = function () { $scope.SetAODwindowStoreData($rootScope.MULTI_VIEW_ID, 'parentSlugName', 'ADAM-on-demand'); $scope.loadAdamVideo($rootScope.MULTI_VIEW_ID); } $scope.loadAdamVideo = function (windowviewid) { $scope.DisableUI(); $scope.jsPanelID = 'aodImagePanel' + '_' + windowviewid; var tittle = $scope.GetAODwindowStoreData(windowviewid, 'currentViewTitle'); var aodlink = $rootScope.aodDomainName+ $scope.GetAODwindowStoreData(windowviewid, 'aodUrl'); var courseid = $scope.GetAODwindowStoreData(windowviewid, 'courseId'); var uid = $scope.GetAODwindowStoreData(windowviewid, 'uid'); var requestType = $scope.GetAODwindowStoreData(windowviewid, 'requestType'); var aodSiteUrl = aodlink+"?SessionId=" + $rootScope.userData.SessionId + "&Courseid=" + courseid + "&type="+requestType +"&uID=" + uid+ ",_self"; //var aodSiteUrl = aodlink+"?SessionId=1625199179202" + "&Courseid=" + courseid + "&type="+requestType +"&uID=" + uid+ ",_self"; $scope.jsPanelWidth = $(window).outerWidth() - 20; $scope.jsPanelHeight = $(window).outerHeight() - 140; $scope.jsPanelLeft = 1; $scope.jsPanelTop = 55; if (aodlink.length > 0 ) { $scope.jsPanelVideo = $.jsPanel({ id: $scope.jsPanelID, selector: '.aodView', theme: 'success', currentController: 'AODController', parentSlug: $scope.GetAODwindowStoreData(windowviewid, 'parentSlugName'), content: '