ModuleService456.js
3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var ATLAS_ANATOMY = 'Atlas Anatomy';
var CLINICAL_ILLUSTRATION = 'Clinical Illustrations';
var CLINICAL_ANIMATION = 'Clinical Animations';
var OpenedModuleItemList = [];
var ModDetail = [];
AIA.service("ModuleService", function ($http, $q, DataService) {
var deferred = $q.defer();
this.loadModuleDataBasedOnModuleName = function (moduleName) {
var tileHtml;
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) {
var AtlasAnatomyData = result;
var data = new jinqJs()
.from(AtlasAnatomyData.root.Item)
.orderBy([{ field: '_Title', sort: 'asc' }])
.select();
var tileHTML;
angular.forEach(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);
var ImageName = value._TileImageName;
var imagePath = "~/../content/images/aa/thumbnails/" + value._TileImageName;
//$scope.TileViewId = value._Id;
tileHTML = $('<div id="' + value._Id + '" class="col-sm-3 col-md-3" title = "' + value._Title + '" data-ng-click="openModuleItem()">'
+ '<div class="thumbnail" >'
+ '<img class="tinyImg" id="' + value._Title + '"ng-src="' + imagePath + '" alt="" title="" >'
+ '<div class="caption"><p>' + value._Title + '</p></div></a></div></div>');//.appendTo('#grid-view');
})
var deferred = $q.defer();
return tileHTML
.then(function (response) {
// promise is fulfilled
//debugger;
deferred.resolve(response.data);
// promise is returned
return deferred.promise;
}, function (response) {
// the following line rejects the promise
deferred.reject(response);
// promise is returned
return deferred.promise;
})
;
}
)}
});