Commit d7ebbfa510b48c6068724eb7e84f18fc4f088ba1

Authored by Nikita Kulshreshtha
1 parent 022962b1

fixed 3d anatomy bug i.e when user goes back open a view again view does not appear.

400-SOURCECODE/AIAHTML5.Web/app/controllers/3dAController.js
1   -AIA.controller("3dAController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile",
2   -function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile) {
3   -
4   -
5   - $scope.showTabButton = false;
6   - $scope.threeDAnatomyData;
7   - $scope.Id;
8   - $scope.$on('$viewContentLoaded', function (event) {
9   - var currentURL = $location.path();
10   - var selectedModuleName = '';
11   - //set module title
12   - angular.forEach($rootScope.userModules, function (value, key) {
13   - if (value.slug === currentURL.replace('/', '')) {
14   - selectedModuleName = value.name;
15   - }
16   - $rootScope.currentActiveModuleTitle = selectedModuleName;
17   - })
18   - if ($rootScope.refreshcheck == null) {
19   - $location.path('/');
20   - }
21   - $scope.scroll();
22   - var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json')
23   - promise.then(
24   - function (result) {
25   - $scope.threeDAnatomyData = result;
26   -
27   - // $scope.selectedThreeDAdata = $scope.threeDAnatomyData.root.ThreeDAData;
28   -
29   - $scope.selectedThreeDAdata = new jinqJs()
30   - .from($scope.threeDAnatomyData.root.ThreeDAData)
31   - .orderBy([{ field: '_Title', sort: 'asc' }])
32   - .select();
33   -
34   - // console.log($scope.selectedCIListViewData);
35   - $('#grid-view').empty();
36   - angular.forEach($scope.selectedThreeDAdata, function (value, key) {
37   - $scope.imagePath = "~/../content/images/3da/thumbnails/" + value._ThumbnailImage;
38   -
39   - var $el = $('<div id="3dView' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '">'
40   - + '<div class="thumbnail">'
41   - + '<img id="' + value._id + '"ng-src="' + $scope.imagePath + '" alt="" title="' + value._Title + '" data-ng-click="Open3DModel($event)" >'
42   - + '<div class="caption"><p>' + value._Title + '</p></div></div></div>').appendTo('#grid-view');
43   -
44   -
45   - $compile($el)($scope);
46   -
47   - $(".sidebar").mCustomScrollbar({
48   - autoHideScrollbar: true,
49   - //theme:"rounded"
50   - });
51   -
52   - });
53   -
54   - },
55   - function (error) {
56   - // handle errors here
57   - console.log(' $scope.threeDAnatomyData = ' + error.statusText);
58   - }
59   - );
60   -
61   - });
62   - $scope.scroll = function () {
63   - // $window.scrollTo(0, 0);
64   - $("html,body").scrollTop(0);
65   - //alert("scroll");
66   - }
67   - $scope.IsVisible = function () {
68   - //$scope.scroll();
69   -
70   - $location.url("/3dAnatomy");
71   -
72   - }
73   -
74   -
75   - $scope.Open3DModel = function ($event) {
76   - $rootScope.currentBodyViewId = $event.currentTarget.id;
77   - if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
78   - var ThreeDTitle = [];
79   - ThreeDTitle = new jinqJs()
80   - .from($scope.selectedThreeDAdata)
81   - .where('_id = ' + $event.currentTarget.id)
82   - .select('_Title');
83   -
84   - $rootScope.ViewTitle = ThreeDTitle[0]._Title;
85   - }
86   - else {
87   - $rootScope.ViewTitle = $event.currentTarget.textContent;
88   -
89   - }
90   -
91   -
92   - localStorage.setItem("currentViewTitleFromJson", $rootScope.ViewTitle);
93   - localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
94   -
95   - var u = $location.url();
96   - $location.url('/3d-anatomy-details');
97   -
98   - }
99   -
100   - $scope.Open3DModelBody = function () {
101   -
102   - if ($rootScope.refreshcheck == null) {
103   - $location.path('/');
104   -
105   - }
106   - $rootScope.isLoading = true;
107   - $('#spinner').css('visibility', 'visible');
108   - //alert($rootScope.getLocalStorageValue("currentBodyViewId"));
109   - $scope.voId3D = $rootScope.getLocalStorageValue("currentBodyViewId");
110   -
111   - //alert($scope.voId3D);
112   -
113   -
114   - //once you get id in scope push detail in jspanel content
115   -
116   - var openViews;
117   - if ($rootScope.openViews.length > 0) {
118   - openViews = new jinqJs()
119   - .from($rootScope.openViews)
120   - .where("BodyViewId==" + $scope.voId3D)
121   - .select();
122   - }
123   - var counter = 1;
124   - var tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson");
125   -
126   - if (openViews != null && openViews.length > 0) {
127   - angular.forEach(openViews, function (value, key) {
128   -
129   - if (value.body - views == tittle) {
130   - tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++;
131   - $rootScope.currentActiveViewTitle = tittle;
132   - localStorage.setItem("currentViewTitle", tittle);
133   - }
134   -
135   - });
136   - }
137   - else {
138   - localStorage.setItem("currentViewTitle", tittle);
139   -
140   - }
141   -
142   - // alert($rootScope.getLocalStorageValue("currentViewTitle"));
143   -
144   - var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json')
145   - promise.then(
146   - function (result) {
147   - $scope.threeDAnatomyData = result;
148   -
149   - var clicked3dAview = [];
150   - clicked3dAview = new jinqJs().from($scope.threeDAnatomyData.root.ThreeDAData)
151   - .where('_id == ' + $scope.voId3D)
152   - .select('_Title', '_3dimagepath');
153   - $scope.Selected3DImagePath = clicked3dAview[0]._3dimagepath;
154   - $scope.threeDBodySystemTitle = clicked3dAview[0]._Title;
155   -
156   - if (clicked3dAview.length > 0) {
157   -
158   - $rootScope.isLoading = false;
159   - $('#spinner').css('visibility', 'hidden');
160   -
161   - $.jsPanel({
162   - id: '3DImagePanel',
163   - selector: '.threeDView',
164   - theme: 'success',
165   - currentController: '3dAController',
166   - parentSlug: '3d-anatomy-list',
167   - content: '<div class="col-sm-12">' +
168   - '<object data="' + $scope.Selected3DImagePath + '" width="100%" height="800px" type="image/svg+xml"></object>' +
169   - '</div><script>$(document).ready(function(){var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {var threeDivWidth = $("#ThreeDView").css("width");$("#ThreeDView").css({"left":"0px","width":"100%","min-idth": threeDivWidth}); var jspanelContainerWidth = $(".jsPanel-content").css("width"); $(".jsPanel-content").css({ "width": "100%", "min-width": jspanelContainerWidth}); $("#3DImagePanel").css("width", "100%"); }});</script>',
170   - title: $rootScope.getLocalStorageValue("currentViewTitle"),
171   - position: {
172   - top: 70,
173   - left: 1,
174   - },
175   -
176   - size: { width: $(window).outerWidth() - 20, height: $(window).outerHeight() - 10 },
177   -
178   - });
179   -
180   - $rootScope.currentSlug = '3d-anatomy-details';
181   -
182   - $rootScope.openViews.push(
183   - {
184   - "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
185   - "slug": $rootScope.currentSlug
186   - });
187   -
188   -
189   - }
190   -
191   -
192   - },
193   - function (error) {
194   - // handle errors here
195   - console.log(' $scope.CIllustrationData = ' + error.statusText);
196   - }
197   -
198   - );
199   - $('#ThreeDView').css("height", $(window).outerHeight());
200   -
201   - $('#ThreeDView').css("width", $(window).outerWidth());
202   -
203   - }
204   -
205   -
206   -
207   -}]
208   -
209   -
210   -
  1 +AIA.controller("3dAController", ["$scope", "$rootScope", "pages", "$log", '$http', 'DataService', '$filter', '$location', '$document', '$sce', "$compile",
  2 +function ($scope, $rootScope, pages, log, $http, DataService, $filter, $location, $document, $sce, $compile) {
  3 +
  4 +
  5 + $scope.showTabButton = false;
  6 + $scope.threeDAnatomyData;
  7 + $scope.Id;
  8 + $scope.$on('$viewContentLoaded', function (event) {
  9 + var currentURL = $location.path();
  10 + var selectedModuleName = '';
  11 + //set module title
  12 + angular.forEach($rootScope.userModules, function (value, key) {
  13 + //if (value.slug === currentURL.replace('/', '')) {
  14 + if (value.slug === "3d-anatomy-list") {
  15 + selectedModuleName = value.name;
  16 + }
  17 + $rootScope.currentActiveModuleTitle = selectedModuleName;
  18 + })
  19 + if ($rootScope.refreshcheck == null) {
  20 + $location.path('/');
  21 + }
  22 + $scope.scroll();
  23 + var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json')
  24 + promise.then(
  25 + function (result) {
  26 + $scope.threeDAnatomyData = result;
  27 +
  28 + // $scope.selectedThreeDAdata = $scope.threeDAnatomyData.root.ThreeDAData;
  29 +
  30 + $scope.selectedThreeDAdata = new jinqJs()
  31 + .from($scope.threeDAnatomyData.root.ThreeDAData)
  32 + .orderBy([{ field: '_Title', sort: 'asc' }])
  33 + .select();
  34 +
  35 + // console.log($scope.selectedCIListViewData);
  36 + $('#grid-view').empty();
  37 + angular.forEach($scope.selectedThreeDAdata, function (value, key) {
  38 + $scope.imagePath = "~/../content/images/3da/thumbnails/" + value._ThumbnailImage;
  39 +
  40 + var $el = $('<div id="3dView' + value._id + '" class="col-sm-3 col-md-2" title = "' + value._Title + '">'
  41 + + '<div class="thumbnail">'
  42 + + '<img id="' + value._id + '"ng-src="' + $scope.imagePath + '" alt="" title="' + value._Title + '" data-ng-click="Open3DModel($event)" >'
  43 + + '<div class="caption"><p>' + value._Title + '</p></div></div></div>').appendTo('#grid-view');
  44 +
  45 +
  46 + $compile($el)($scope);
  47 +
  48 + $(".sidebar").mCustomScrollbar({
  49 + autoHideScrollbar: true,
  50 + //theme:"rounded"
  51 + });
  52 +
  53 + });
  54 +
  55 + },
  56 + function (error) {
  57 + // handle errors here
  58 + console.log(' $scope.threeDAnatomyData = ' + error.statusText);
  59 + }
  60 + );
  61 +
  62 + });
  63 + $scope.scroll = function () {
  64 + // $window.scrollTo(0, 0);
  65 + $("html,body").scrollTop(0);
  66 + //alert("scroll");
  67 + }
  68 + $scope.IsVisible = function () {
  69 + //$scope.scroll();
  70 +
  71 + $location.url("/3dAnatomy");
  72 +
  73 + }
  74 +
  75 +
  76 + $scope.Open3DModel = function ($event) {
  77 + $rootScope.currentBodyViewId = $event.currentTarget.id;
  78 + if ($event.currentTarget.textContent !== null && typeof ($event.currentTarget.textContent) !== "undefined") {
  79 + var ThreeDTitle = [];
  80 + ThreeDTitle = new jinqJs()
  81 + .from($scope.selectedThreeDAdata)
  82 + .where('_id = ' + $event.currentTarget.id)
  83 + .select('_Title');
  84 +
  85 + $rootScope.ViewTitle = ThreeDTitle[0]._Title;
  86 + }
  87 + else {
  88 + $rootScope.ViewTitle = $event.currentTarget.textContent;
  89 +
  90 + }
  91 +
  92 +
  93 + localStorage.setItem("currentViewTitleFromJson", $rootScope.ViewTitle);
  94 + localStorage.setItem("currentBodyViewId", $event.currentTarget.id);
  95 +
  96 + var u = $location.url();
  97 + $location.url('/3d-anatomy-details');
  98 +
  99 + }
  100 +
  101 + $scope.Open3DModelBody = function () {
  102 +
  103 + if ($rootScope.refreshcheck == null) {
  104 + $location.path('/');
  105 +
  106 + }
  107 + $rootScope.isLoading = true;
  108 + $('#spinner').css('visibility', 'visible');
  109 + //alert($rootScope.getLocalStorageValue("currentBodyViewId"));
  110 + $scope.voId3D = $rootScope.getLocalStorageValue("currentBodyViewId");
  111 +
  112 + //alert($scope.voId3D);
  113 +
  114 +
  115 + //once you get id in scope push detail in jspanel content
  116 +
  117 + var openViews;
  118 + //if ($rootScope.openViews.length > 0) {
  119 + // openViews = new jinqJs()
  120 + // .from($rootScope.openViews)
  121 + // .where("BodyViewId==" + $scope.voId3D)
  122 + // .select();
  123 + //}
  124 + // var counter = 1;
  125 + var tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson");
  126 + $rootScope.currentActiveViewTitle = tittle;
  127 + localStorage.setItem("currentViewTitle", tittle);
  128 +
  129 + //if (openViews != null && openViews.length > 0) {
  130 + // angular.forEach(openViews, function (value, key) {
  131 +
  132 + // if (value.body - views == tittle) {
  133 + // tittle = $rootScope.getLocalStorageValue("currentViewTitleFromJson") + counter++;
  134 + // $rootScope.currentActiveViewTitle = tittle;
  135 + // localStorage.setItem("currentViewTitle", tittle);
  136 + // }
  137 +
  138 + // });
  139 + //}
  140 + //else {
  141 + // localStorage.setItem("currentViewTitle", tittle);
  142 +
  143 + //}
  144 +
  145 + // alert($rootScope.getLocalStorageValue("currentViewTitle"));
  146 +
  147 + var promise = DataService.getJson('~/../content/data/json/3da/3da_dat_contentlist.json')
  148 + promise.then(
  149 + function (result) {
  150 + $scope.threeDAnatomyData = result;
  151 +
  152 + var clicked3dAview = [];
  153 + clicked3dAview = new jinqJs().from($scope.threeDAnatomyData.root.ThreeDAData)
  154 + .where('_id == ' + $scope.voId3D)
  155 + .select('_Title', '_3dimagepath');
  156 + $scope.Selected3DImagePath = clicked3dAview[0]._3dimagepath;
  157 + $scope.threeDBodySystemTitle = clicked3dAview[0]._Title;
  158 +
  159 + if (clicked3dAview.length > 0) {
  160 +
  161 + $rootScope.isLoading = false;
  162 + $('#spinner').css('visibility', 'hidden');
  163 +
  164 + $.jsPanel({
  165 + id: '3DImagePanel',
  166 + selector: '.threeDView',
  167 + theme: 'success',
  168 + currentController: '3dAController',
  169 + parentSlug: '3d-anatomy-list',
  170 + content: '<div class="col-sm-12">' +
  171 + '<object data="' + $scope.Selected3DImagePath + '" width="100%" height="800px" type="image/svg+xml"></object>' +
  172 + '</div><script>$(document).ready(function(){var $ua = navigator.userAgent; if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {var threeDivWidth = $("#ThreeDView").css("width");$("#ThreeDView").css({"left":"0px","width":"100%","min-idth": threeDivWidth}); var jspanelContainerWidth = $(".jsPanel-content").css("width"); $(".jsPanel-content").css({ "width": "100%", "min-width": jspanelContainerWidth}); $("#3DImagePanel").css("width", "100%"); }});</script>',
  173 + title: $rootScope.getLocalStorageValue("currentViewTitle"),
  174 + position: {
  175 + top: 70,
  176 + left: 1,
  177 + },
  178 +
  179 + size: { width: $(window).outerWidth() - 20, height: $(window).outerHeight() - 10 },
  180 +
  181 + });
  182 +
  183 + $rootScope.currentSlug = '3d-anatomy-details';
  184 +
  185 + $rootScope.openViews.push(
  186 + {
  187 + "module": $rootScope.currentActiveModuleTitle, "bodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
  188 + "slug": $rootScope.currentSlug
  189 + });
  190 +
  191 +
  192 + }
  193 +
  194 +
  195 + },
  196 + function (error) {
  197 + // handle errors here
  198 + console.log(' $scope.CIllustrationData = ' + error.statusText);
  199 + }
  200 +
  201 + );
  202 + $('#ThreeDView').css("height", $(window).outerHeight());
  203 +
  204 + $('#ThreeDView').css("width", $(window).outerWidth());
  205 +
  206 + }
  207 +
  208 +
  209 +
  210 +}]
  211 +
  212 +
  213 +
211 214 );
212 215 \ No newline at end of file
... ...