'use strict'; AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService","AuthenticationService","LoginConstants", function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants) { //$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.setListManagerZindex = false; $rootScope.lastX; $rootScope.lastY; $rootScope.CommonData; $rootScope.shapeType; $rootScope.globalSetting = { ethnicity: 'W', modesty: 'Y', }; $rootScope.formsetting = { ethnicity: null, modesty: null }; $rootScope.isModestyOn; $rootScope.isModestyOff; $rootScope.SetSettingActiveTab; $rootScope.disableMenuannotation = "disableMenuannotation"; $rootScope.disableMenuoption = "disableMenuoption"; $rootScope.menuLabExer; $rootScope.menuLabExer = 0; $rootScope.fontSizes; $rootScope.fontWeight; $rootScope.fontStyle; $rootScope.textAlignmt; $rootScope.fontColor; $rootScope.underlineText; $rootScope.textArea; $rootScope.fontFamily; $rootScope.TextPropertyArray = []; $rootScope.modifySavedText = []; $rootScope.TextRectangleArr = []; $rootScope.rectDimension = []; $rootScope.isEraseToolSelected = false; $rootScope.isMousedownOnPaintCanvas = false; //opacity code $rootScope.shapestyleOpacity = 1; $rootScope.shapestyleFillColor = "#fff"; $rootScope.shapestyleFillBorderColor = "black"; $rootScope.shapestyleborderWidth = 2; $rootScope.shapestyleborderStyles = "solid"; $rootScope.initializeAIA = function () { $rootScope.isLoading = false; $rootScope.isVisibleLogin = true; getUserDetails(); } $rootScope.userInfo = { username: null, password: null }; $rootScope.userData ; $rootScope.userModules ; $rootScope.AuthenticateUser = function (userInfo) { $rootScope.isVisibleLogin = false; if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) { alert("Please enter correct information"); } else { AuthenticationService.authenticateUser(userInfo) .then( function (result) { if (result == LoginConstants.USER_NOT_FOUND) { alert(result); } else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { alert(result); } else { if (result.loginId != undefined || result.loginId != "" || result.loginId != null) { $rootScope.userData = result; $rootScope.userModules = result.modules; $rootScope.isVisibleLogin = false; localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); } } }, function (error) { console.log(' Error in authentication = ' + error.statusText); alert(LoginConstants.ERROR_IN_FECTHING_DETAILS); }); } } $rootScope.LogoutUser = function () { localStorage.removeItem('loggedInUserDetails'); document.location = '/'; $rootScope.isVisibleLogin = true; } function getUserDetails() { //Retain logged in user details var currentUserDetails = localStorage.getItem('loggedInUserDetails'); if (currentUserDetails) { try { var userInfo = JSON.parse(storedUser); if (userInfo.loginId != undefined || userInfo.loginId != "" || userInfo.loginId != null) { $rootScope.isVisibleLogin = false; $rootScope.userData = userInfo; $rootScope.userModules = userInfo.modules; } } catch (e) { localStorage.removeItem('loggedInUserDetails'); } } } $(document).ready(function () { getUserDetails(); }); $rootScope.$on("$locationChangeSuccess", function () { $rootScope.isLeftMenuActive = function (moduleUrl) { return moduleUrl === $location.path(); } if (($location.url() == "/da-body-view")) { $rootScope.disableMenuannotation = " "; $rootScope.disableMenuoption = " "; } else if (($location.url() == "/clinical-illustrations-detail") || ($location.url() == "/clinical-animations-detail")) { $rootScope.disableMenuannotation = " "; $rootScope.disableMenuoption = " "; $rootScope.disableSubMenu = "disableSubMenu"; } else { $rootScope.disableMenuannotation = "disableMenuannotation"; $rootScope.disableMenuoption = "disableMenuoption"; $rootScope.disableSubMenu = ""; $rootScope.CloseAnnotationTool(); $rootScope.CloseListManager(); angular.element('#modal-settings').css('display','none'); if ($location.url() == "/lab-exercises") { $rootScope.menuLabExer = 0; } if ($rootScope.menuLabExer == 1) { $rootScope.disableMenuoption = " "; } } }); //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(); if ($('#jsPanel-1').length > 0) $('#jsPanel-1').remove(); $location.url('/' + slug); $rootScope.$broadcast('jsPanelCloseEvent', true); } //called on jsanel minimize $rootScope.setState = function (state, title) { 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, "bodyView": title, "state": state, "BodyViewId": $rootScope.currentBodyViewId, "slug": $rootScope.currentSlug } ); } } } if (state == 'max') { $('#daBodyview').css('width', '100%') } } $rootScope.ClearIframe = function () { if ($('#daImagePanel') != null) $('#daImagePanel').remove(); if ($('#jsPanel-1').length > 0) $('#jsPanel-1').remove(); $rootScope.hideScrollbar(); } //ends $rootScope.hideScrollbar = function () { $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true, //theme:"rounded" }); } $rootScope.isFontFamilyLoaded = false; //annotation tool custom events $rootScope.ShowAnnotationWindow = function () { //7904 if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "CI") { if ($rootScope.disableAnnotationtoolOnListManager == true) { $('#AnnotaionPopupDiv').find('a,input, textarea, button, select,img,div').attr('disabled', 'disabled'); $('#slider-range-min-2').slider('disable'); $("#annotationpaintbrushsize").attr('disabled', 'disabled'); // $rootScope.disableAnnotationTB = false; } else { $('#AnnotaionPopupDiv').find('input, textarea, button, select,img,div').removeAttr('disabled', 'disabled'); $('#slider-range-min-2').slider('enable'); $("#annotationpaintbrushsize").removeAttr('disabled', 'disabled'); } // document.getElementById('modelbackground').style.display = "block"; // document.getElementById('modeleditstyle').style.display = "block"; } if ($rootScope.MenuModuleName == "CA") { $("#annotationpaintbrushsize").attr("href", "#"); } $("#OnIdentify").addClass("annotationtoolbartab"); $("#annotationToolBarOptions").addClass("active"); $("#annotationButton").addClass("active"); $rootScope.isAnnotationWindowOpen = true; $(".annotationTollbar").css("display", "block"); $rootScope.$broadcast('annotationToolEvent', true); // $("#canvasPaint").css("display", "none"); // $("#canvas").css("display", "none"); var FontFamilyJson = '~/../content/data/json/settings/fontstyle.json'; if ($rootScope.isFontFamilyLoaded == false) { DataService.getJson(FontFamilyJson) .then( function (result) { $rootScope.AnnotationFontFamily = result; // alert($rootScope.AnnotationFontFamily.FontStyle.length); for (var i = 0; i <= $rootScope.AnnotationFontFamily.FontFamily.length - 1; i++) { $("#selected-font-family").append(""); } $rootScope.isFontFamilyLoaded = true; }, function (error) { console.log(error.statusText) } ) } } $rootScope.CloseAnnotationTool = function () { console.log('close'); $("#OnIdentify").removeClass("annotationtoolbartab"); $("#DrawMode").removeClass("annotationtoolbartab"); $('.btnCursor').removeClass('activebtncolor'); $("#annotationButton").removeClass("active"); $("#annotationToolBarOptions").removeClass("active"); $(".annotationTollbar").css("display", "none"); $rootScope.isAnnotationWindowClose = true; // $("#canvasPaint").css("display", "none"); // $("#canvas").css("display", "none"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.switchCanvas(); } $rootScope.CIAnotationIdentifyModeOff = false; $rootScope.OnIdentifyClick = function () { $("#OnIdentify").addClass("annotationtoolbartab"); $("#DrawMode").removeClass("annotationtoolbartab"); // $rootScope.isIdetifyClicked = true; // $rootScope.isDrawingToolSelected = false; // debugger; if ($rootScope.CIAnotationIdentifyModeOff == true) { $('.btnCursor').removeClass('activebtncolor'); } else { // $("#canvasPaint").css("display", "none"); // $("#canvas").css("display", "none"); // $("#canvasPaint").css("z-index", "0"); // $("#canvas").css("z-index", "0"); $('.btnCursor').removeClass('activebtncolor'); } $rootScope.isAnnotaionToolBarDrawingModeActive = false; $rootScope.switchCanvas(); } $rootScope.DrawingMode = function () { //Annotation History $rootScope.isAnnotaionToolBarDrawingModeActive = true; $("#OnIdentify").removeClass("annotationtoolbartab"); $("#DrawMode").addClass("annotationtoolbartab"); $('.btnCursor').addClass('activebtncolor'); $rootScope.switchCanvas(); // $("#canvasPaint").css("display", "block"); // $("#canvas").css("display", "block"); } // Dissectible Anatomy > Settings should be disable if Annotation is Open. $rootScope.ShowSettingWindow = function () { if ($(".annotationTollbar").css("display") == "block") { // alert("already open"); $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); } else { $('#modal-settings').css("display", "block"); $("#modelsettingsbackground").css("display", "block"); } } //----Annotation Toolbar: Jcanvas----- $rootScope.DrawLine = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Line"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-line").addClass("activebtncolor"); } $rootScope.DrawPin = function (e) { $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.switchCanvas(); $rootScope.setListManagerZindex = true; $rootScope.shapeType = "Pin"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-pin").addClass("activebtncolor"); } $rootScope.Cursor = function () { $rootScope.switchCanvas(); $rootScope.shapeType = "cursor"; $(".btn-annotation").removeClass("activebtncolor"); // $("#" + e.currentTarget.id).removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.DrawRectangle = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Rectangle"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-rectangle").addClass("activebtncolor"); } $rootScope.paintBrush = function () { $rootScope.isAnnotaionToolBarDrawingModeActive = false; if ($rootScope.disableAnnotationtoolOnListManager == true) { $rootScope.switchCanvas(); var canvasPaintZindex = $('#canvasPaint').css("z-index"); //x var canvasZindex = $('#canvas').css("z-index"); //y var listManagerZindex = $('#listManager').css("z-index"); //z if (canvasPaintZindex > canvasZindex) { $('#listManager').css("z-index", canvasPaintZindex); } else { $('#listManager').css("z-index", canvasZindex); } } else { // $('.btnCursor').addClass('activebtncolor'); $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvasToPaintCanvas(); $rootScope.shapeType = "FreeStylePaint"; var btnBrushSizeValue = $("#btnBrushSize").val(); $rootScope.shapeSize = parseInt(btnBrushSizeValue); $("#annotationpaintbrushsize").attr("data-size", $rootScope.shapeSize); $("#annotationpaintbrushsize").attr("data-color", $rootScope.shapestyleColorWithOpacity); if ($rootScope.shapeSize == '') { $('#canvasPaint').sketch({ defaultSize: 1 }); } else { $('#canvasPaint').sketch(); } } $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-brush").addClass("activebtncolor"); } $rootScope.switchCanvasToPaintCanvas = function (e) { var canvasPaint_zIndex = $('#canvasPaint').css("z-index"); var canvas_zIndex = $('#canvas').css("z-index"); if (canvas_zIndex > canvasPaint_zIndex) { canvasPaint_zIndex = parseInt(canvas_zIndex) + 1; } else { canvasPaint_zIndex = parseInt(canvasPaint_zIndex) + 1; } $('#canvasPaint').css("z-index", canvasPaint_zIndex); } $rootScope.DrawCircle = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Circle"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-circle").addClass("activebtncolor"); } $rootScope.DrawArrow = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "Arrow"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-arrow").addClass("activebtncolor"); } $rootScope.DrawText = function () { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.switchCanvas(); $rootScope.shapeType = "TextArea"; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-Text").addClass("activebtncolor"); } $rootScope.DrawPolygon = function () { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.shapeType = "DrawPolygon"; } $rootScope.switchCanvas = function () { var x = $('#canvasPaint').css("z-index"); var y = $('#canvas').css("z-index"); if (x > y) { y = parseInt(x) + 1; } else { y = parseInt(y) + 1; } $('#canvas').css("z-index", y); } $rootScope.EraseDrawing = function () { $rootScope.isAnnotaionToolBarDrawingModeActive = false; $rootScope.switchCanvas(); $rootScope.isEraseToolSelected = true; //$rootScope.switchCanvasToPaintCanvas(); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-erase").addClass("activebtncolor"); } $rootScope.isShapeSyleOkBtnClicked = false; $rootScope.setPropertiesForShapes = function (id) { $rootScope.isShapeSyleOkBtnClicked = true; if ((document.getElementById('fill-option').checked == false) && (document.getElementById('Outline-Option').checked == false)) { // $('#btnShapeStyle').attr('disabled', 'disabled'); } else { //$('#btnShapeStyle').removeAttr('disabled', 'disabled'); document.getElementById('modelbackground').style.display = "none"; document.getElementById('modeleditstyle').style.display = "none"; $rootScope.shapestyleOpacity = $("#" + id).css('opacity'); $("#shapeStyleDiv").parent().css("opacity", $rootScope.shapestyleOpacity); $rootScope.shapestyleFillColor = $("#" + id).css('background-color'); $rootScope.shapeStyleColorRGBA = $rootScope.shapestyleFillColor.replace("rgb", "rgba"); $rootScope.shapestyleColorWithOpacity = $rootScope.shapeStyleColorRGBA.substring(0, $rootScope.shapeStyleColorRGBA.length - 1) + " " + "," + $rootScope.shapestyleOpacity + ")"; $("#shapeStyleDiv").css("background-color", $rootScope.shapestyleFillColor); $rootScope.shapestyleborderColor = $("#" + id).parent().css("border-top-color"); // $("#shapeStyleDiv").parent().css("border-color", $rootScope.shapestyleborderColor); $rootScope.borderDimensions = $("#" + id).parent().css("border-top-width"); document.getElementById("shapeStyleDiv").parentNode.style.border = $rootScope.borderDimensions + " " + "solid" + " " + $rootScope.shapestyleborderColor; // $("#shapeStyleDiv").parent().css("border-width", $rootScope.shapestyleborderWidthSeparatingPixel); var borderDimensions = $rootScope.borderDimensions; var borderDimensionSplitArray = borderDimensions.split("p"); $rootScope.shapestyleborderWidth = borderDimensionSplitArray[0]; $rootScope.shapestyleborderStyles = "solid"; $('#editshapestyle').modal('hide'); //Edit Shape Style popup should open at it's default position $("#modeleditstyle").css({ "left": "40%", "right": "0", "top": "70px" }); } } $rootScope.enableAnnotationToolBar = function () { if ($rootScope.disableAnnotationTB == true) { document.getElementById('modelbackground').style.display = "none"; document.getElementById('modeleditstyle').style.display = "none"; } else { document.getElementById('modelbackground').style.display = "block"; document.getElementById('modeleditstyle').style.display = "block"; // alert(document.getElementById('outlinedivId').style.border); // alert(document.getElementById('imgOpacity').style.backgroundColor); $('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", document.getElementById('imgOpacity').style.backgroundColor); $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", document.getElementById('outlinedivId').style.border); if ($('#modeleditstyle').css("display") == "block") { //Check if the modal is already showing var previewOpacity = $('#imgOpacity').css("opacity"); $('#slider-range-min-4 div.ui-slider-range-min').css("width", (previewOpacity * 100) + "%"); $('#slider-range-min-4 span.ui-slider-handle').css("left", (previewOpacity * 100) + "%"); }; } } $rootScope.enableEditShapeTooltip = function () { $("#edit-block").addClass("custom-tooltip-annotation"); $(".custom-tooltip-annotation").css('display', 'block'); } $rootScope.disableEditShapeTooltip = function () { $(".custom-tooltip-annotation").css('display', 'none'); $("#edit-block").removeClass("custom-tooltip-annotation"); } $rootScope.disableAnnotationToolBar = function () { if ($rootScope.isShapeSyleOkBtnClicked == false) { $('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(255,255,255)"); $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", "rgb(0,0,0)"); var previewBorderColor = $("#outlineColor span.minicolors-swatch-color").css('background-color'); $(".marginTopBtm10 div.outlinediv").css("border-color", previewBorderColor); var previewBgColor = $("#editstylebackgroundcolor span.minicolors-swatch-color").css('background-color'); $("#imgOpacity").css("background-color", previewBgColor); $('#borderWidthCanvasElement').val(1); $('.marginTopBtm10 div.outlinediv').css("border-width", 1); $("#imgOpacity").css("opacity", 1); $(".marginTopBtm10 div.outlinediv").css("opacity", 1); //$("#borderWidthCanvasElement").change(function () { // $(".marginTopBtm10 div.outlinediv").css("border-color", x); //}); } else { var previewBgColor = $("#shapeStyleDiv").css('background-color'); var previewBorderColor = $('#previewBorder').css('border-color'); var previewBorderWidth = $('#previewBorder').css('border-width'); var previewOpacity = $('#previewBorder').css('opacity'); $('#editstylebackgroundcolor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", previewBgColor); $("#imgOpacity").css("background-color", previewBgColor); $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color", previewBorderColor); $(".marginTopBtm10 div.outlinediv").css("border-color", previewBorderColor); $('.marginTopBtm10 div.outlinediv').css("border-width", previewBorderWidth); $('#borderWidthCanvasElement').val(previewBorderWidth.split("px")); $("#imgOpacity").css("opacity", previewOpacity); $(".marginTopBtm10 div.outlinediv").css("opacity", previewOpacity); } document.getElementById('modelbackground').style.display = "none"; document.getElementById('modeleditstyle').style.display = "none"; //Edit Shape Style popup should open at it's default position $("#modeleditstyle").css({ "left": "40%", "right": "0", "top": "70px" }); } //--Common code of Annotation Toolbar for CI and DA------- $rootScope.DrawLineOnModuleItem = function (canvasId, LineNumber, shapestyleborderColor, shapestyleborderWidth, offsetX1, offsetY1, x, y) { if ($rootScope.isLinePreviewCompleted == true) { $rootScope.isLinePreviewCompleted = false; $(canvasId).addLayer({ name: 'Line_' + LineNumber, layer: true, type: 'line', draggable: true, strokeStyle: shapestyleborderColor, strokeWidth: shapestyleborderWidth, rounded: true, x1: offsetX1, y1: offsetY1, x2: x, y2: y, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseout: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, radius: 0 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseover: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } } }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.DrawRectangleOnModuleItem = function (canvasId, RectNumber, shapestyleFillColor, shapestyleborderColor, shapestyleOpacity, shapestyleborderWidth, offsetX1, offsetY1, x, y) { if ($rootScope.isRectanglePreviewCompleted == true) { $rootScope.isRectanglePreviewCompleted = false; $(canvasId).addLayer({ layer: true, name: 'Rect_' + RectNumber, fillStyle: shapestyleFillColor, type: 'rectangle', draggable: true, strokeStyle: shapestyleborderColor, opacity: shapestyleOpacity, strokeWidth: shapestyleborderWidth, fromCenter: false, x: offsetX1, y: offsetY1, width: (x - offsetX1), height: (y - offsetY1), resizeFromCenter: false, dblclick: function () { }, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 5, height: 5, cornerRadius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseout: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: 'pink', strokeStyle: 'yellow', strokeWidth: 0, width: 0, height: 0, cornerRadius: 0 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseover: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $(canvasId).setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 5, height: 5, cornerRadius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } } }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.DrawCircleOnModuleItem = function (canvasId, CircleNumber, shapestyleOpacity, shapestyleborderColor, shapestyleborderWidth, shapestyleFillColor, offsetX1, offsetY1, x, y) { // console.log("up"+ offsetX1 + " " + offsetY1 + " " + (x - offsetX1) + " " + (y - offsetY1)); if ($rootScope.isCirclePreviewCompleted == true) { $rootScope.isCirclePreviewCompleted = false; $(canvasId).addLayer({ layer: true, name: 'Circle_' + CircleNumber, type: 'ellipse', opacity: shapestyleOpacity, draggable: true, strokeStyle: shapestyleborderColor, strokeWidth: shapestyleborderWidth, fillStyle: shapestyleFillColor, fromCenter: false, x: (offsetX1), y: (offsetY1), width: (x - offsetX1), height: (y - offsetY1), // Place a handle at each side and each corner resizeFromCenter: false, handlePlacement: 'both', click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseout: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, // width: 0, height: 0, radius: 0 } }).drawLayers(); } else { layer.draggable = false; } }, mouseover: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } } }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.DrawArrowOnModuleItem = function (canvasId, ArrowNumber, shapestyleborderColor, shapestyleborderWidth, offsetX1, offsetY1, x, y) { if ($rootScope.isArrowPreviewCompleted == true) { $rootScope.isArrowPreviewCompleted = false; $('#canvas').drawLine({ layer: true, name: 'Arrow_' + ArrowNumber, draggable: true, strokeStyle: shapestyleborderColor, strokeWidth: shapestyleborderWidth, rounded: true, startArrow: true, arrowRadius: 7, arrowAngle: 90, x1: offsetX1, y1: offsetY1, x2: x, y2: y, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); // $("#canvas").removeLayer(layer.name).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseout: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, // width: 0, height: 0, radius: 0 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseover: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } } }); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.DrawPinOnModuleItem = function (canvasId, PinNumber, offsetX1, offsetY1, x, y, PinArcNumber) { if ($rootScope.isPinPreviewCompleted == true) { $rootScope.isPinPreviewCompleted = false; var radial = $('#canvas').createGradient({ x1: 50, y1: 50, x2: 50, y2: 50, r1: 10, r2: 30, c1: 'rgba(100, 50, 0,0)', c2: 'grey' }); $(canvasId).drawLine({ draggable: true, layer: true, name: "Pin_" + PinNumber, groups: ["Pin_" + PinNumber], dragGroups: ["Pin_" + PinNumber], strokeStyle: 'black', strokeWidth: 2, x1: offsetX1, y1: offsetY1, x2: x, y2: y, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.shapeTypePin = "Pin"; $rootScope.canvasLayerNameCollection = []; var pinLine_layer = layer.name; var pinLine_layer_split = pinLine_layer.split("_"); var pinArcName = "ArcPin_"; var pinResult = pinArcName.concat(pinLine_layer_split[1]); $rootScope.canvasLayerNameCollection.push({ pinName: layer.name, ArcName: pinResult }); $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseout: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 0, // width: 0, height: 0, radius: 0 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseover: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $(canvasId).setLayer(layer.name, { handle: { type: 'arc', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, // width: 5, height: 5, radius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } } }).drawArc({ draggable: true, name: "ArcPin_" + PinArcNumber, // name: "Pin_" + $rootScope.resetPin, layer: true, groups: ["Pin_" + PinNumber], dragGroups: ["Pin_" + PinNumber], strokeStyle: 'grey', strokeWidth: 2, fillStyle: radial, x: offsetX1, y: offsetY1, radius: 5, add: function (layer) { $rootScope.PinArcNumber = layer.name; // $scope.arr = []; }, }).drawLayers(); } $('.btnCursor').trigger('click'); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.TextEditorFunctionality = function (canvasId, TextNumber, offsetX1, offsetY1, resetTextRect, shapestyleOpacity, shapestyleborderColor, shapestyleborderWidth, shapestyleFillColor, x, y) { if ($rootScope.isTextAreaPreviewCompleted == true) { $rootScope.isTextAreaPreviewCompleted = false; $('#canvas').drawText({ layer: true, draggable: true, // opacity: $rootScope.shapestyleOpacity, name: 'TextArea_' + $rootScope.TextNumber, groups: ['TextArea_' + $rootScope.TextNumber], dragGroups: ['TextArea_' + $rootScope.TextNumber], fillStyle: '#36c', strokeWidth: 0, x: $rootScope.offsetX1, y: $rootScope.offsetY1, fromCenter: false, fontSize: '14pt', align: "left", fontFamily: 'Verdana, sans-serif', text: '', add: function (layer) { $rootScope.TextID = layer.name; } }) // Draw rect as wide as the text .drawRect({ layer: true, name: "TextRect_" + $rootScope.TextNumber, dragGroups: ['shapes'], opacity: $rootScope.shapestyleOpacity, strokeStyle: $rootScope.shapestyleborderColor, fromCenter: false, strokeWidth: $rootScope.shapestyleborderWidth, fillStyle: $rootScope.shapestyleFillColor, x: $rootScope.offsetX1, y: $rootScope.offsetY1, width: ($rootScope.x - $rootScope.offsetX1), height: ($rootScope.y - $rootScope.offsetY1), resizeFromCenter: false, add: function (layer) { $rootScope.TextAreaRectID = layer.name; $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y }); // $rootScope.CurrentWidth = layer.width; // $rootScope.CurrentHeight = layer.height; }, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push(layer.name); $('#canvas').setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 5, height: 5, cornerRadius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, dblclick: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.IsTextAlreadySave = false; var RectNameArray = (layer.name).split("_"); var TextAreaRectangleName = "TextArea_"; var TextAreaRectNameConcat = TextAreaRectangleName.concat(RectNameArray[1]); $rootScope.TextAreaRectID = layer.name; $rootScope.TextID = TextAreaRectNameConcat; $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y }); $("#annotationTextModal").css("padding-right", "0px"); document.getElementById('modelbackground').style.display = "block"; $("#annotationTextModal").modal("toggle"); $("#text_area").val(''); $("#text_area").css({ "font-family": "Arial", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" }); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" }); // $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").addClass("ActiveDefaultColorAnnotation"); $("#selected-font-family option:eq(0)").prop('selected', true); $("#selected-font-size option:eq(0)").prop('selected', true); $("#text-italic").removeClass("ActiveFormattingButtonClass"); $("#text-bold").removeClass("ActiveFormattingButtonClass"); $("#text-underline").removeClass("ActiveFormattingButtonClass"); $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass"); } else { //jcanvas property layer.draggable = false; } }, mouseout: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.canvasLayerNameCollection = []; $('#canvas').setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: 'pink', strokeStyle: 'yellow', strokeWidth: 0, width: 0, height: 0, cornerRadius: 0 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, mouseover: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $('#canvas').setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 5, height: 5, cornerRadius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } } }); // Annotation: Edit Text option is missing. $("#annotationTextModal").css("padding-right", "0px"); $("#annotationTextModal").modal("toggle"); document.getElementById('modelbackground').style.display = "block"; } $('.btnCursor').trigger('click'); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" }); $("#text_area").val(''); $("#text_area").css({ "font-family": "Arial", "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" }); $("#selected-font-family option:eq(0)").prop('selected', true); $("#selected-font-size option:eq(0)").prop('selected', true); // $("#text_area").css({ " font-family": 'Verdana, sans-serif', "font-size": "14px", "font-weight": "normal", "font-style": "normal", "color": "#000", "text-align": "left", "text-decoration": "none" }); $("#text-italic").removeClass("ActiveFormattingButtonClass"); $("#text-bold").removeClass("ActiveFormattingButtonClass"); $("#text-underline").removeClass("ActiveFormattingButtonClass"); $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass"); $(".btn-annotation").removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); } $rootScope.clicked = true; $rootScope.offsetX1 = 0; $rootScope.offsetY1 = 0; $rootScope.x = 0; $rootScope.y = 0; $rootScope.mousePressed = false; $rootScope.lastX; $rootScope.lastY; var ctx; $rootScope.OnPaintCanvasMouseDown = function (event) { var canvasElement = document.getElementById("canvas"); var ctx = canvasElement.getContext("2d"); // var x = event.clientX; // var y = event.clientY; $rootScope.offsetX1 = 0; $rootScope.offsetY1 = 0; //alert($location.path()); var canvasDiv = document.getElementById('canvasDiv'); var verticalScrollPosition = canvasDiv.scrollTop; var horizontlScrollPosition = canvasDiv.scrollLeft; $rootScope.offsetX1 = event.offsetX; $rootScope.offsetY1 = event.offsetY; ctx.clearRect(0, 0, 2277, 3248); $rootScope.clicked = true; // alert("x:"+$rootScope.offsetX1 + " y:" + $rootScope.offsetY1); canvasElement.addEventListener('mousemove', $rootScope.OnPaintCanvasMouseMove, false); } $rootScope.rectNumber = 0; $rootScope.LineNumber = 0; $rootScope.CircleNumber = 0; $rootScope.ArrowNumber = 0; $rootScope.PinNumber = 0; $rootScope.PinArcNumber = 0; $rootScope.ObjectIndex = 0; $rootScope.ArcObjectIndex = 0; $rootScope.PinObjectIndex = 0; $rootScope.TextNumber = 0; $rootScope.resetTextSave = 0; $rootScope.ObjectIndexSave = 0; var arrayRect = {}; var storeLine = ''; $rootScope.OnPaintCanvasMouseUp = function (event) { if (!$rootScope.clicked) { return; } var AnnotationCanvas = document.getElementById('canvas'); AnnotationCanvas.removeEventListener('mousemove', $rootScope.OnPaintCanvasMouseMove, false); $(".line").remove(); $(".arrow").remove(); $(".pin").remove(); $(".circle").remove(); $(".rectangle").remove(); $(".textarea").remove(); $rootScope.clicked = false; $rootScope.x = 0; $rootScope.y = 0; var canvasDiv = document.getElementById('canvasDiv'); var verticalScrollPosition = canvasDiv.scrollTop; var horizontlScrollPosition = canvasDiv.scrollLeft; $rootScope.x = event.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left; $rootScope.y = event.pageY + verticalScrollPosition - $('#canvasDiv').offset().top; var canvasElement = document.getElementById("canvas"); var ctx = canvasElement.getContext("2d"); var canvasPaintElement = document.getElementById("canvasPaint"); var PaintCanvasctx = canvasPaintElement.getContext("2d"); switch ($rootScope.shapeType) { case "cursor": ctx.beginPath(); PaintCanvasctx.beginPath(); break; case "Line": $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.LineNumber = $rootScope.ObjectIndex++; // $rootScope.isLinePreviewCompleted = true; $rootScope.DrawLineOnModuleItem('#canvas', $rootScope.LineNumber, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y) break; case "Rectangle": $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.rectNumber = $rootScope.ObjectIndex++; // $rootScope.isRectanglePreviewCompleted = true; $rootScope.DrawRectangleOnModuleItem('#canvas', $rootScope.rectNumber, $rootScope.shapestyleFillColor, $rootScope.shapestyleborderColor, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y); break; case "Circle": $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.CircleNumber = $rootScope.ObjectIndex++; // $rootScope.isCirclePreviewCompleted = true; $rootScope.DrawCircleOnModuleItem('#canvas', $rootScope.CircleNumber, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.shapestyleFillColor, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y); break; case "Arrow": $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.ArrowNumber = $rootScope.ObjectIndex++; //$rootScope.isArrowPreviewCompleted = true; $rootScope.DrawArrowOnModuleItem('#canvas', $rootScope.ArrowNumber, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y); break; case "Pin": $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.PinNumber = $rootScope.PinObjectIndex++; $rootScope.PinArcNumber = $rootScope.ArcObjectIndex++; //$rootScope.isPinPreviewCompleted = true; $rootScope.DrawPinOnModuleItem('#canvas', $rootScope.PinNumber, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y, $rootScope.PinArcNumber); break; case "TextArea": $rootScope.isAnnotaionToolBarDrawingModeActive = true; $rootScope.IsTextAlreadySave = false; $("#text_area").val(''); // Draw text $rootScope.resetTextRect = $rootScope.ObjectIndex++; $rootScope.TextNumber = $rootScope.ObjectIndex++; // $rootScope.isTextAreaPreviewCompleted = true; $rootScope.TextEditorFunctionality('#canvas', $rootScope.TextNumber, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.resetTextRect, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.shapestyleFillColor, $rootScope.x, $rootScope.y); break; case "DrawPolygon": break; } //} } $rootScope.OnPaintCanvasMouseMove = function (event) { var canvasDiv = document.getElementById('canvasDiv'); var verticalScrollPosition = canvasDiv.scrollTop; var horizontlScrollPosition = canvasDiv.scrollLeft; $rootScope.MouseMoveXAxis = event.pageX + horizontlScrollPosition - $('#canvasDiv').offset().left; $rootScope.MouseMoveYAxis = event.pageY + verticalScrollPosition - $('#canvasDiv').offset().top; switch ($rootScope.shapeType) { case "Line": $(".line").remove(); $rootScope.isLinePreviewCompleted = true; $("#canvasDiv").append("
"); $rootScope.Annotationangle(); break; case "Arrow": $(".arrow").remove(); $rootScope.isArrowPreviewCompleted = true; $("#canvasDiv").append("