'use strict'; AIA.controller("TileViewListController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "BodyRegions", "BodySystems", "ViewOrientations", "ImageTypes", "$timeout", "Modules", "$routeParams", "DataService","ModuleService" , function ($scope, $rootScope, $compile, $http, $log, $location, BodyRegions, BodySystems, ViewOrientations, ImageTypes, $timeout, Modules, $routeParam, DataService,ModuleService) { var ATLAS_ANATOMY = 'Atlas Anatomy'; var CLINICAL_ILLUSTRATION ='Clinical Illustrations'; var CLINICAL_ANIMATION='Clinical Animations'; var moduleData = []; $scope.AllBodyRegion = []; $scope.AllBodySystem = []; $scope.AllOrientation = []; $scope.AllImageType = []; $scope.moduleData = []; $scope.loadForModuleById = function (moduleId) { $scope.moduleId = moduleId; console.log('loadForModuleById is called') $scope.moduleName = Modules[moduleId].Name; $scope.loadDataForModule($scope.moduleName); } $scope.loadDataForModule = function (moduleName) { //0. load filter static data $scope.AllBodyRegion = BodyRegions; $scope.AllBodySystem = BodySystems; $scope.AllOrientation = ViewOrientations; $scope.AllImageType = ImageTypes; //1. load dynamic data for module specific images var jsonPath; if(moduleName==ATLAS_ANATOMY) { jsonPath ='~/../content/data/json/aa/aa_dat_contentlist.json'; } else if(moduleName == CLINICAL_ANIMATION) { //to do, in next phase of project jsonPath ='~/../content/data/json/ca/ca_dat_contentlist.json'; } else if(moduleName == CLINICAL_ILLUSTRATION) { //to do, in next phase of project jsonPath ='~/../content/data/json/ci/ci_dat_contentlist.json'; } var promise = DataService.getJson(jsonPath) promise.then( function (result) { $scope.AtlasAnatomyData = result; $scope.data = new jinqJs() .from($scope.AtlasAnatomyData.root.Item) .orderBy([{ field: '_Title', sort: 'asc' }]) .select(); //console.log($scope.selectedCIListViewData); //$('#grid-view').empty(); angular.forEach($scope.data, function (value, key) { // $rootScope.moduleData = []; $scope.moduleData.push({ "id": value._Id, "imageID": value._ImageId, "TileName": value._TileImageName, "DivImageTitle": value._Title }); // $scope.moduleData.push(value._ImageId); // $scope.moduleData.push(value._TileImageName); $scope.ImageName = value._TileImageName; $scope.imagePath = "~/../content/images/aa/thumbnails/" + value._TileImageName; $scope.TileViewId = value._Id; var $el = $('
' + '
' + '' + '

' + value._Title + '

').appendTo('#grid-view'); $compile($el)($scope); //$(".sidebar").mCustomScrollbar({ // autoHideScrollbar: true, // //theme:"rounded" //}); }); $scope.scroll(); }, function (error) { // handle errors here console.log(' $scope.IllustrationData = ' + error.statusText); } ); } $scope.scroll = function () { $("html,body").scrollTop(0); } $scope.openModuleItem = function ($event) { var moduleItemDataToBeSaved = []; for(var i=0;i<=$scope.moduleData.length-1;i++) { if ($scope.moduleData[i].DivImageTitle == event.target.id) { alert($scope.moduleData[i].imageID); moduleItemDataToBeSaved.push($scope.moduleData[i].imageID, $scope.moduleData[i].id,$scope.moduleName); } } ModuleService.SaveOpenedModules(moduleItemDataToBeSaved); //var isSaved= ModuleService.SaveOpenedModules(moduleDetails); //alert(isSaved); } }]);