'use strict'; AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", function ($rootScope, Modules, $log, $location, $timeout) { //$scope.pageToOpen = { // name: 'MainMenu' //}; $rootScope.pageToOpen = 'app/widget/MainMenu.html'; $rootScope.currentBodyViewId; $rootScope.currentActiveModuleTitle = 'Welcome to A.D.A.M. Interactive Anatomy';//Modules[0].Name; $rootScope.currentActiveViewTitle; $rootScope.cuurentActiveModuleId; $rootScope.openModules = []; $rootScope.openViews = []; $rootScope.currentSlug; $rootScope.jsPanelTitle; $rootScope.ViewTitle; $rootScope.isLoading = false; $rootScope.isAnnotationWindowOpen = false; $rootScope.isDrawingToolSelected = false; $rootScope.isIdetifyClicked = true; $rootScope.paint = false; $rootScope.clickX = new Array(); $rootScope.clickY = new Array(); $rootScope.clickDrag = new Array(); $rootScope.isLineDrawSelecyed = false; $rootScope.isAnnotationWindowClose = false; $rootScope.lastX; $rootScope.lastY; $rootScope.CommonData; //jspanel functionality.. $rootScope.openParent = function (slug) { // debugger; var openViews = $rootScope.openViews; if (openViews.length > 0) { $rootScope.openViews.splice(openViews.length - 1); } if (openViews.length > 0) { var lastOpenMoudle = $rootScope.openViews[openViews.length - 1]; } $('#daImagePanel').remove(); $location.url('/' + slug); $rootScope.$broadcast('jsPanelCloseEvent', true); } //called on jsanel minimize $rootScope.setState = function (state, title) { debugger; var alreadyOpenThisView = new jinqJs() .from($rootScope.openViews) .where("body-views == " + title) .select(); var k = 0; if (alreadyOpenThisView != null) { for (var i = 0; i < $rootScope.openViews.length; i++) { k++; if ($rootScope.openViews[i].body - views == title) { $rootScope.openViews.splice((k - 1), 1); $rootScope.openViews.push( { "module": $rootScope.currentActiveModuleTitle, "body-views": title, "state": state, "BodyViewId": $rootScope.currentBodyViewId, "slug": $rootScope.currentSlug } ); } } } if (state == 'max') { $('#daBodyview').css('width', '100%') } } $rootScope.ClearIframe = function () { if ($('#daImagePanel') != null) $('#daImagePanel').remove(); $rootScope.hideScrollbar(); } //ends $rootScope.hideScrollbar = function () { $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); } //annotation tool custom events $rootScope.ShowAnnotationWindow = function () { $rootScope.isAnnotationWindowOpen = true; $(".annotationTollbar").css("display", "block"); $rootScope.$broadcast('annotationToolEvent',true); } $rootScope.CloseAnnotationTool = function () { console.log('close') $(".annotationTollbar").css("visibility", "hidden"); $rootScope.isAnnotationWindowClose = true; } $rootScope.OnIdentifyClick = function () { $rootScope.isIdetifyClicked = true; $rootScope.isDrawingToolSelected = false; } //draw line on canvas $rootScope.DrawLine = function () { $rootScope.isIdetifyClicked = false; $rootScope.isDrawingToolSelected = true; $rootScope.isLineDrawSelecyed = true; } $rootScope.AddClick=function (x, y, dragging) { $rootScope.clickX.push(x); $rootScope.clickY.push(y); $rootScope.clickDrag.push(dragging); } $rootScope.Redraw = function () { var context = document.getElementById('paintCanvas').getContext('2d'); context.clearRect(0, 0, context.canvas.width, context.canvas.height); // Clears the canvas context.strokeStyle = "#FFFFFF"; context.lineJoin = "round"; context.lineWidth = 5; for (var i = 0; i < $rootScope.clickX.length; i++) { context.beginPath(); if ($rootScope.clickDrag[i] && i) { context.moveTo($rootScope.clickX[i - 1], $rootScope.clickY[i - 1]); } else { context.moveTo($rootScope.clickX[i] - 1, $rootScope.clickY[i]); } context.lineTo($rootScope.clickX[i], $rootScope.clickY[i]); context.closePath(); context.stroke(); } } $rootScope.PaintCanvasMousedownListener = function (canvasContext,x,y) { if ($rootScope.isLineDrawSelecyed == true) { canvasContext.lineWidth = 0.1; //$scope.paintCanvasContext.lineJoin = 'round'; //$scope.paintCanvasContext.lineCap = 'round'; canvasContext.strokeStyle = 'red'; canvasContext.beginPath(); //var canvasOffset = $("#myCanvas").offset(); //var offsetX = canvasOffset.left; //var offsetY = canvasOffset.top; canvasContext.moveTo(x, y); } } $rootScope.PaintCanvasMouseupListener = function (canvasContext) { if ($scope.isLineDrawSelecyed == true) { } } $rootScope.PaintCanvasMousemoveListener = function (canvasContext,x,y) { if ($rootScope.isLineDrawSelecyed == true) { console.log('hm moving') canvasContext.lineTo(x, y); canvasContext.stroke(); } } $rootScope.Draw = function (x, y, isDown,context) { if (isDown) { context.beginPath(); context.strokeStyle = '#000000'; context.lineWidth = 1//$('#selWidth').val(); context.lineJoin = "round"; context.moveTo($rootScope.lastX, $rootScope.lastY); context.lineTo(x, y); context.closePath(); context.stroke(); } $rootScope.lastX = x; $rootScope.lastY = y; } $rootScope.EraseDrawing = function () { document.getElementById('paintCanvas').getContext('2d').setTransform(1, 0, 0, 1, 0, 0); document.getElementById('paintCanvas').getContext('2d').clearRect(0, 0, document.getElementById('paintCanvas').getContext('2d').canvas.width, document.getElementById('paintCanvas').getContext('2d').canvas.height); } //list manager function $rootScope.ShowListManager = function () { console.log('ShowListManager') $('#listManager').css('display', 'block'); $("#listManager").css("visibility", "visible"); $('#listManager').draggable(); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $rootScope.islistManagerEventAlredayDispachted = true; $rootScope.$broadcast('listManagerEvent', true); } function fillListManagerTerms() { var len = $rootScope.openModules.length; var openViewLen = $rootScope.openViews.length; var currentOpenModuleId = $rootScope.openModules[len - 1].ModuleId; var currentOpenViewId = $rootScope.openViews[openViewLen - 1].BodyViewId; if (currentOpenModuleId == 1) { } } $rootScope.CloseListManager = function () { console.log('close') $rootScope.isListManagerSelected = false; $('#listManager').css('display', 'none'); $("#listManager").css("visibility", "hidden"); // $rootScope.isAnnotationWindowClose = true; // if('#termList') if ($('#termList option').length > 0) { //$('#termList option') = null; //$('#termList').innerHTML=''; $('#termList') .find('option') .remove() .end() if($('#termList option').length > 0){ } } } }] );