Commit b8cc46a25dcfd1afdd64efbcb109b9968adee0a6

Authored by Nikita Kulshreshtha
1 parent 3777775b

added iPad detection code for getting full view on iPad and by default body view…

… loads with middle horizontal scroll position
400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js
1 -'use strict'; 1 + 'use strict';
2 2
3 -AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "GetJsonService",  
4 -function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, GetJsonService) { 3 +AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams",
  4 +function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam) {
5 5
6 $scope.genderId = ""; 6 $scope.genderId = "";
7 $scope.BodyViewData; 7 $scope.BodyViewData;
@@ -20,30 +20,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -20,30 +20,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
20 $scope.daCounter = 1; 20 $scope.daCounter = 1;
21 21
22 22
23 - $scope.genderId = "";  
24 - $scope.BodyViewData;  
25 - $scope.selectedGenderBodyViewData;  
26 - $scope.imagePath = "";  
27 - $scope.BodyRegionData;  
28 - $scope.BodyRegionCordinatesData;  
29 - $scope.isTransparencyActivated;  
30 - $scope.BodyLayerData;  
31 - $scope.VocabTermData;  
32 - $scope.TermNumberData;  
33 - $scope.bodyViewId = 0;  
34 - //view specific constants  
35 - $scope.voId;  
36 - $scope.layerNumber;  
37 - $scope.daCounter = 1;  
38 -  
39 - $scope.isBodylayerdataLoaded = false;  
40 - $scope.isBodyRegionDataLoaded = false;  
41 - $scope.showme = false;  
42 - $scope.IsVisible = function () {  
43 - $scope.showme = $scope.showme ? false : true;  
44 - }  
45 -  
46 -  
47 //get the DA body view list based on selected gender 23 //get the DA body view list based on selected gender
48 $scope.getDAViewList = function ($event) { 24 $scope.getDAViewList = function ($event) {
49 25
@@ -171,138 +147,124 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -171,138 +147,124 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
171 //da-body-view functions 147 //da-body-view functions
172 148
173 $scope.openBodyView = function () { 149 $scope.openBodyView = function () {
174 - //debugger;  
175 150
176 - //load bodyRegion data  
177 - var brViewdata = GetJsonService.getJson('~/../content/data/json/da_dat_brview.json')  
178 - brViewdata.then(  
179 - function (result) {  
180 - // debugger;  
181 - $scope.BodyRegionData = result;  
182 - $scope.isBodyRegionDataLoaded = true;  
183 - // alert('da_dat_brview= ' + result)  
184 151
185 - //get layer data for body view  
186 - GetJsonService.getAnotherJson('~/../content/data/json/da_dat_layer_1.json')  
187 - .then(  
188 - function (result) {  
189 - //debugger;  
190 -  
191 - $scope.BodyLayerData = result;  
192 - $scope.isBodylayerdataLoaded = true; 152 + //load json
  153 + $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) {
  154 + $scope.TermNumberData = data;
  155 + })
  156 + .error(function (data, status, headers, config) {
  157 + console.log(data);
  158 + });
  159 +
  160 +
  161 + //load vocabterm data
  162 + $http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) {
  163 + $scope.VocabTermData = data;
  164 + })
  165 + .error(function (data, status, headers, config) {
  166 + console.log(data);
  167 + });
  168 +
  169 +
193 170
194 - //load json for annotations  
195 - $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) {  
196 - $scope.TermNumberData = data;  
197 - })  
198 - .error(function (data, status, headers, config) {  
199 - console.log(data);  
200 - }); 171 + var openViews;
  172 + var currentBodyViewId = localStorage.getItem("currentBodyViewId");
  173 + // debugger;
  174 + if ($rootScope.openViews.length > 0) {
  175 + openViews = new jinqJs()
  176 + .from($rootScope.openViews)
  177 + .where("BodyViewId==" + currentBodyViewId)
  178 + .select();
  179 + }
  180 + var counter = 1;
201 181
202 - //load vocabterm data  
203 - $http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) {  
204 - $scope.VocabTermData = data;  
205 - })  
206 - .error(function (data, status, headers, config) {  
207 - console.log(data);  
208 - }); 182 + // var tittle = $rootScope.ViewTitle;
  183 + var tittle = localStorage.getItem("currentViewTitleFromJson");
209 184
  185 + if (openViews != null && openViews.length > 0) {
  186 + angular.forEach(openViews, function (value, key) {
  187 +
  188 + if (value.BodyView == tittle) {
  189 + tittle = localStorage.getItem("currentViewTitleFromJson") + counter++;
  190 + $rootScope.currentActiveViewTitle = tittle;
  191 + localStorage.setItem("currentViewTitle", tittle);
  192 + }
210 193
  194 + });
  195 + }
  196 + else {
  197 + localStorage.setItem("currentViewTitle", tittle);
  198 + }
  199 +
  200 + $http({ method: 'GET', url: '~/../content/data/json/da_dat_brview.json' }).success(function (data) {
  201 +
  202 + $scope.BodyRegionData = data;
  203 + // console.log($scope.BodyRegionData);
  204 + // alert(' $scope.BodyRegionData= ' + $scope.BodyRegionData)
  205 + })
  206 + .error(function (data, status, headers, config) {
  207 + console.log(data);
  208 + });
211 209
212 - var openViews;  
213 210
214 - var currentBodyViewId = localStorage.getItem("currentBodyViewId");  
215 - // debugger;  
216 - if ($rootScope.openViews.length > 0) {  
217 - openViews = new jinqJs()  
218 - .from($rootScope.openViews)  
219 - .where("BodyViewId==" + currentBodyViewId)  
220 - .select();  
221 - }  
222 - var counter = 1; 211 + // Load Layer data
  212 + $http({ method: 'GET', url: '~/../content/data/json/da_dat_layer_1.json' }).success(function (data) {
  213 + // debugger
  214 + $scope.BodyLayerData = data;
  215 + // console.log($scope.BodyLayerData);
223 216
224 - // var tittle = $rootScope.ViewTitle;  
225 - var tittle = localStorage.getItem("currentViewTitleFromJson"); 217 + })
  218 + .error(function (data, status, headers, config) {
  219 + console.log(data);
  220 + });
226 221
227 - if (openViews != null && openViews.length > 0) {  
228 - angular.forEach(openViews, function (value, key) { 222 + $.jsPanel({
  223 + id: 'daImagePanel',
  224 + selector: '.daBodyView',
  225 + theme: 'success',
  226 + ajax: {
  227 + url: 'app/views/da/da-view.html'
  228 + },
  229 + title: localStorage.getItem("currentViewTitle"),
  230 + position: {
  231 + top: 70,
  232 + left: 1,
  233 + },
  234 +
  235 + size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },
229 236
230 - if (value.BodyView == tittle) {  
231 - tittle = localStorage.getItem("currentViewTitleFromJson") + counter++;  
232 - $rootScope.currentActiveViewTitle = tittle;  
233 - localStorage.setItem("currentViewTitle", tittle);  
234 - } 237 + });
235 238
236 - });  
237 - }  
238 - else {  
239 - localStorage.setItem("currentViewTitle", tittle);  
240 - }  
241 239
242 240
243 - $.jsPanel({  
244 - id: 'daImagePanel',  
245 - selector: '.daBodyView',  
246 - theme: 'success',  
247 - ajax: {  
248 - url: 'app/views/da/da-view.html'  
249 - },  
250 - title: localStorage.getItem("currentViewTitle"),  
251 - position: {  
252 - top: 70,  
253 - left: 1,  
254 - },  
255 241
256 - size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },  
257 242
258 - });  
259 243
  244 + // $rootScope.openViewsDA.push({ "ViewId": 1 });
  245 + $rootScope.currentSlug = 'da-body-view';
260 246
  247 + //hide scrollbar
261 248
262 249
  250 + $rootScope.openViews.push(
  251 + {
  252 + "module": $rootScope.currentActiveModuleTitle, "BodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,
  253 + "slug": $rootScope.currentSlug
  254 + }
  255 + );
  256 + // debugger;
263 257
  258 + var e1 = angular.element(document.getElementById("daBodyview"));
  259 + $timeout(function () { $compile(e1.contents())($scope) }, 250);
  260 + // $compile(e1.contents())($scope);
264 261
265 - // $rootScope.openViewsDA.push({ "ViewId": 1 });  
266 - $rootScope.currentSlug = 'da-body-view'; 262 + $('#daBodyview').css("height", $(window).outerHeight());
267 263
268 - //hide scrollbar 264 + $('#daBodyview').css("width", $(window).outerWidth());
269 265
  266 + $timeout(function () { $scope.LoadDefaultLayerImage() }, 350);
270 267
271 - $rootScope.openViews.push(  
272 - {  
273 - "module": $rootScope.currentActiveModuleTitle, "BodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId,  
274 - "slug": $rootScope.currentSlug  
275 - }  
276 - );  
277 - // debugger;  
278 -  
279 - var e1 = angular.element(document.getElementById("daBodyview"));  
280 - $timeout(function () { $compile(e1.contents())($scope) }, 250);  
281 - // $compile(e1.contents())($scope);  
282 -  
283 - $('#daBodyview').css("height", $(window).outerHeight());  
284 -  
285 - $('#daBodyview').css("width", $(window).outerWidth());  
286 -  
287 - // debugger  
288 - if ($scope.isBodylayerdataLoaded) {  
289 - $timeout(function () { $scope.LoadDefaultLayerImage() }, 350);  
290 - }  
291 - },  
292 - function (error) {  
293 - // handle errors here  
294 - console.log(' $scope.BodyLayerData= ' + error.statusText);  
295 - }  
296 - );  
297 - },  
298 - function (error) {  
299 - // handle errors here  
300 - console.log(' $scope.BodyRegionData = ' + error.statusText);  
301 - }  
302 - );  
303 -  
304 - // debugger  
305 -  
306 } 268 }
307 269
308 angular.element(document).ready(function () { 270 angular.element(document).ready(function () {
@@ -327,9 +289,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -327,9 +289,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
327 $scope.layerNumber = 0; 289 $scope.layerNumber = 0;
328 $scope.skinTone = DA[0].ethnicity; 290 $scope.skinTone = DA[0].ethnicity;
329 291
330 - // $timeout(function () { $scope.CalculateImageCordinates($scope.voId); }, 350); 292 + $timeout(function () { $scope.CalculateImageCordinates($scope.voId); }, 350);
  293 +
331 294
332 - $scope.CalculateImageCordinates($scope.voId);  
333 }; 295 };
334 296
335 297
@@ -362,6 +324,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -362,6 +324,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
362 324
363 325
364 326
  327 + $('#daBodyview').css('width', '100%')
365 328
366 //set height of canvas div and left tool bar as per window size 329 //set height of canvas div and left tool bar as per window size
367 $scope.BodyRegionCordinatesData = []; // create an empty array 330 $scope.BodyRegionCordinatesData = []; // create an empty array
@@ -462,11 +425,20 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -462,11 +425,20 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
462 425
463 426
464 }); 427 });
  428 + // debugger;
  429 + // var isiOSSafari = (navigator.userAgent.match(/like Mac OS X/i)) ? true : false;
  430 + var isiOSSafari = (navigator.userAgent.match(/iPad/i)) ? true : false;
465 431
466 //set scrollbars on canvas and hide loading label 432 //set scrollbars on canvas and hide loading label
467 $('#daLoaderLabel').css('visibility', 'hidden') 433 $('#daLoaderLabel').css('visibility', 'hidden')
468 $('#canvasDiv').css('overflow', 'scroll') 434 $('#canvasDiv').css('overflow', 'scroll')
469 - $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2) 435 + if (isiOSSafari) {
  436 + $('#canvasDiv').scrollLeft($('#canvasDiv').width()+150)
  437 +
  438 + }
  439 + else {
  440 + $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2)
  441 + }
470 // $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition) 442 // $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition)
471 $('#canvasDiv').scrollTop(50) 443 $('#canvasDiv').scrollTop(50)
472 var abc = $scope.BodyRegionCordinatesData; 444 var abc = $scope.BodyRegionCordinatesData;
@@ -521,7 +493,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -521,7 +493,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
521 493
522 494
523 $scope.GetImageSource = function (bodyRegionId) { 495 $scope.GetImageSource = function (bodyRegionId) {
524 - // debugger; 496 + // debugger;
525 var dataLength = $scope.BodyLayerData.Layers.DataLayer.length; 497 var dataLength = $scope.BodyLayerData.Layers.DataLayer.length;
526 498
527 //set max for LayerNumber input 499 //set max for LayerNumber input
@@ -552,7 +524,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -552,7 +524,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
552 } 524 }
553 525
554 else { 526 else {
555 - for (z = 0; z <= SelectedLayerData.BodyRegion.length; z++) { 527 + for (var z = 0; z <= SelectedLayerData.BodyRegion.length; z++) {
556 var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId; 528 var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId;
557 if (bodyRegion == bodyRegionId) { 529 if (bodyRegion == bodyRegionId) {
558 return "content/images/DA/BodyViews/" + $scope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName; 530 return "content/images/DA/BodyViews/" + $scope.voId + "/layers/" + $scope.layerNumber + "/" + bodyRegionId + "/" + SelectedLayerData.BodyRegion[z].Image._ImageName;
@@ -1040,6 +1012,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo @@ -1040,6 +1012,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo
1040 1012
1041 }] 1013 }]
1042 1014
1043 -);  
1044 1015
1045 -//DAController.$inject = ["$scope", "$rootScope", "$q", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "GetJsonService"]; 1016 +
  1017 +);
1046 \ No newline at end of file 1018 \ No newline at end of file