From b8cc46a25dcfd1afdd64efbcb109b9968adee0a6 Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 9 May 2016 15:25:48 +0530 Subject: [PATCH] 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 | 254 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 113 insertions(+), 141 deletions(-) diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js index 3b9c55c..ad5fcc5 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/DAController.js @@ -1,7 +1,7 @@ -'use strict'; + 'use strict'; -AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "GetJsonService", -function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam, GetJsonService) { +AIA.controller("DAController", ["$scope", "$rootScope", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", +function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Modules, $routeParam) { $scope.genderId = ""; $scope.BodyViewData; @@ -20,30 +20,6 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.daCounter = 1; - $scope.genderId = ""; - $scope.BodyViewData; - $scope.selectedGenderBodyViewData; - $scope.imagePath = ""; - $scope.BodyRegionData; - $scope.BodyRegionCordinatesData; - $scope.isTransparencyActivated; - $scope.BodyLayerData; - $scope.VocabTermData; - $scope.TermNumberData; - $scope.bodyViewId = 0; - //view specific constants - $scope.voId; - $scope.layerNumber; - $scope.daCounter = 1; - - $scope.isBodylayerdataLoaded = false; - $scope.isBodyRegionDataLoaded = false; - $scope.showme = false; - $scope.IsVisible = function () { - $scope.showme = $scope.showme ? false : true; - } - - //get the DA body view list based on selected gender $scope.getDAViewList = function ($event) { @@ -171,138 +147,124 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo //da-body-view functions $scope.openBodyView = function () { - //debugger; - //load bodyRegion data - var brViewdata = GetJsonService.getJson('~/../content/data/json/da_dat_brview.json') - brViewdata.then( - function (result) { - // debugger; - $scope.BodyRegionData = result; - $scope.isBodyRegionDataLoaded = true; - // alert('da_dat_brview= ' + result) - //get layer data for body view - GetJsonService.getAnotherJson('~/../content/data/json/da_dat_layer_1.json') - .then( - function (result) { - //debugger; - - $scope.BodyLayerData = result; - $scope.isBodylayerdataLoaded = true; + //load json + $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) { + $scope.TermNumberData = data; + }) + .error(function (data, status, headers, config) { + console.log(data); + }); + + + //load vocabterm data + $http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) { + $scope.VocabTermData = data; + }) + .error(function (data, status, headers, config) { + console.log(data); + }); + + - //load json for annotations - $http({ method: 'GET', url: '~/../content/data/json/da_dat_tm_sg_1.json' }).success(function (data) { - $scope.TermNumberData = data; - }) - .error(function (data, status, headers, config) { - console.log(data); - }); + var openViews; + var currentBodyViewId = localStorage.getItem("currentBodyViewId"); + // debugger; + if ($rootScope.openViews.length > 0) { + openViews = new jinqJs() + .from($rootScope.openViews) + .where("BodyViewId==" + currentBodyViewId) + .select(); + } + var counter = 1; - //load vocabterm data - $http({ method: 'GET', url: '~/../content/data/json/cm_dat_vocabterm_1.json' }).success(function (data) { - $scope.VocabTermData = data; - }) - .error(function (data, status, headers, config) { - console.log(data); - }); + // var tittle = $rootScope.ViewTitle; + var tittle = localStorage.getItem("currentViewTitleFromJson"); + if (openViews != null && openViews.length > 0) { + angular.forEach(openViews, function (value, key) { + + if (value.BodyView == tittle) { + tittle = localStorage.getItem("currentViewTitleFromJson") + counter++; + $rootScope.currentActiveViewTitle = tittle; + localStorage.setItem("currentViewTitle", tittle); + } + }); + } + else { + localStorage.setItem("currentViewTitle", tittle); + } + + $http({ method: 'GET', url: '~/../content/data/json/da_dat_brview.json' }).success(function (data) { + + $scope.BodyRegionData = data; + // console.log($scope.BodyRegionData); + // alert(' $scope.BodyRegionData= ' + $scope.BodyRegionData) + }) + .error(function (data, status, headers, config) { + console.log(data); + }); - var openViews; - var currentBodyViewId = localStorage.getItem("currentBodyViewId"); - // debugger; - if ($rootScope.openViews.length > 0) { - openViews = new jinqJs() - .from($rootScope.openViews) - .where("BodyViewId==" + currentBodyViewId) - .select(); - } - var counter = 1; + // Load Layer data + $http({ method: 'GET', url: '~/../content/data/json/da_dat_layer_1.json' }).success(function (data) { + // debugger + $scope.BodyLayerData = data; + // console.log($scope.BodyLayerData); - // var tittle = $rootScope.ViewTitle; - var tittle = localStorage.getItem("currentViewTitleFromJson"); + }) + .error(function (data, status, headers, config) { + console.log(data); + }); - if (openViews != null && openViews.length > 0) { - angular.forEach(openViews, function (value, key) { + $.jsPanel({ + id: 'daImagePanel', + selector: '.daBodyView', + theme: 'success', + ajax: { + url: 'app/views/da/da-view.html' + }, + title: localStorage.getItem("currentViewTitle"), + position: { + top: 70, + left: 1, + }, + + size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, - if (value.BodyView == tittle) { - tittle = localStorage.getItem("currentViewTitleFromJson") + counter++; - $rootScope.currentActiveViewTitle = tittle; - localStorage.setItem("currentViewTitle", tittle); - } + }); - }); - } - else { - localStorage.setItem("currentViewTitle", tittle); - } - $.jsPanel({ - id: 'daImagePanel', - selector: '.daBodyView', - theme: 'success', - ajax: { - url: 'app/views/da/da-view.html' - }, - title: localStorage.getItem("currentViewTitle"), - position: { - top: 70, - left: 1, - }, - size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 }, - }); + // $rootScope.openViewsDA.push({ "ViewId": 1 }); + $rootScope.currentSlug = 'da-body-view'; + //hide scrollbar + $rootScope.openViews.push( + { + "module": $rootScope.currentActiveModuleTitle, "BodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, + "slug": $rootScope.currentSlug + } + ); + // debugger; + var e1 = angular.element(document.getElementById("daBodyview")); + $timeout(function () { $compile(e1.contents())($scope) }, 250); + // $compile(e1.contents())($scope); - // $rootScope.openViewsDA.push({ "ViewId": 1 }); - $rootScope.currentSlug = 'da-body-view'; + $('#daBodyview').css("height", $(window).outerHeight()); - //hide scrollbar + $('#daBodyview').css("width", $(window).outerWidth()); + $timeout(function () { $scope.LoadDefaultLayerImage() }, 350); - $rootScope.openViews.push( - { - "module": $rootScope.currentActiveModuleTitle, "BodyView": tittle, "state": 'max', "BodyViewId": $rootScope.currentBodyViewId, - "slug": $rootScope.currentSlug - } - ); - // debugger; - - var e1 = angular.element(document.getElementById("daBodyview")); - $timeout(function () { $compile(e1.contents())($scope) }, 250); - // $compile(e1.contents())($scope); - - $('#daBodyview').css("height", $(window).outerHeight()); - - $('#daBodyview').css("width", $(window).outerWidth()); - - // debugger - if ($scope.isBodylayerdataLoaded) { - $timeout(function () { $scope.LoadDefaultLayerImage() }, 350); - } - }, - function (error) { - // handle errors here - console.log(' $scope.BodyLayerData= ' + error.statusText); - } - ); - }, - function (error) { - // handle errors here - console.log(' $scope.BodyRegionData = ' + error.statusText); - } - ); - - // debugger - } angular.element(document).ready(function () { @@ -327,9 +289,9 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.layerNumber = 0; $scope.skinTone = DA[0].ethnicity; - // $timeout(function () { $scope.CalculateImageCordinates($scope.voId); }, 350); + $timeout(function () { $scope.CalculateImageCordinates($scope.voId); }, 350); + - $scope.CalculateImageCordinates($scope.voId); }; @@ -362,6 +324,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo + $('#daBodyview').css('width', '100%') //set height of canvas div and left tool bar as per window size $scope.BodyRegionCordinatesData = []; // create an empty array @@ -462,11 +425,20 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo }); + // debugger; + // var isiOSSafari = (navigator.userAgent.match(/like Mac OS X/i)) ? true : false; + var isiOSSafari = (navigator.userAgent.match(/iPad/i)) ? true : false; //set scrollbars on canvas and hide loading label $('#daLoaderLabel').css('visibility', 'hidden') $('#canvasDiv').css('overflow', 'scroll') - $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2) + if (isiOSSafari) { + $('#canvasDiv').scrollLeft($('#canvasDiv').width()+150) + + } + else { + $('#canvasDiv').scrollLeft($('#canvasDiv').width() / 2) + } // $('#canvasDiv').scrollLeft($scope.imageHorizontlScrollPosition) $('#canvasDiv').scrollTop(50) var abc = $scope.BodyRegionCordinatesData; @@ -521,7 +493,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo $scope.GetImageSource = function (bodyRegionId) { - // debugger; + // debugger; var dataLength = $scope.BodyLayerData.Layers.DataLayer.length; //set max for LayerNumber input @@ -552,7 +524,7 @@ function ($scope, $rootScope, $compile, $http, $log, $location, $timeout, DA, Mo } else { - for (z = 0; z <= SelectedLayerData.BodyRegion.length; z++) { + for (var z = 0; z <= SelectedLayerData.BodyRegion.length; z++) { var bodyRegion = SelectedLayerData.BodyRegion[z]._BodyRegionId; if (bodyRegion == bodyRegionId) { 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 }] -); -//DAController.$inject = ["$scope", "$rootScope", "$q", "$compile", "$http", "$log", "$location", "$timeout", "DA", "Modules", "$routeParams", "GetJsonService"]; + +); \ No newline at end of file -- libgit2 0.21.4