'use strict'; AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants","UserModules","LoginMessageConstants","AdminService", "AdminConstants", "UserTypeConstants", function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, AdminConstants, UserTypeConstants) { //$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.isMousedownOnPaintCanvas = false; //opacity code $rootScope.shapestyleOpacity = 1; $rootScope.shapestyleFillColor = "#fff"; $rootScope.shapestyleFillBorderColor = "black"; $rootScope.shapestyleborderWidth = 2; $rootScope.shapestyleborderStyles = "solid"; $rootScope.errorMassage = ''; $rootScope.disableFileMenu = "disableFileMenu"; $rootScope.userInfo = { username: null, password: null, emailId: null, havePassword: null, newPassword: null, confirmPassword: null, userMessage: null }; $rootScope.userData; $rootScope.userModules; $rootScope.errorMesaage; $rootScope.isVisibleLogin; $rootScope.haveRoleAdmin; var isfilloptionChecked = ""; var isOutlineOptionChecked = ""; $rootScope.initializeAIA = function () { $rootScope.isLoading = false; //$rootScope.isVisibleLogin = false; //$rootScope.isVisibleResetPass = true; VerifyUrlForQuerystring(); getUserDetails(); } $rootScope.AuthenticateUser = function (userInfo) { if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) { // alert(LoginMessageConstants.USER_CREDENTIALS_MISSING); $rootScope.errorMassage = LoginMessageConstants.USER_CREDENTIALS_MISSING; $("#messageModal").modal('show'); } else { AuthenticationService.authenticateUser(userInfo) .then( function (result) { if (result == 'true') { $rootScope.userModules = UserModules; $rootScope.isVisibleLogin = false; } else { if (result == LoginConstants.USER_NOT_FOUND) { $rootScope.isVisibleLogin = true; // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT); $rootScope.errorMassage = LoginMessageConstants.USER_OR_PASSWORD_INCORRECT; $("#messageModal").modal('show'); } else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { //alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); $rootScope.isVisibleLogin = true; $rootScope.errorMassage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); } 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)); $('#dvUserModulesInfo').modal('show'); var userType = result.userType + ''; if (userType === UserTypeConstants.SUPER_ADMIN) $rootScope.haveRoleAdmin = false; else $rootScope.haveRoleAdmin = true; } } } }, function (error) { console.log(' Error in authentication = ' + error.statusText); // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); $rootScope.isVisibleLogin = true; $rootScope.errorMassage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); }); } } function VerifyUrlForQuerystring() { var url = $location.url(); var field = 'em'; if (url.indexOf('?' + field + ':') != -1) { $rootScope.isVisibleLogin = false; $rootScope.isVisibleResetPass = true; } else { $rootScope.isVisibleLogin = true; $rootScope.isVisibleResetPass = false; } } $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(currentUserDetails); if (userInfo.loginId != undefined || userInfo.loginId != "" || userInfo.loginId != null) { $rootScope.isVisibleLogin = false; $rootScope.userData = userInfo; $rootScope.userModules = userInfo.modules; } } catch (e) { localStorage.removeItem('loggedInUserDetails'); } } } $rootScope.SendMailToUser = function (userInfo, isMailForPassword) { if ((userInfo.emailId != null) && (userInfo.emailId != '')) { if (validateEmail(userInfo.emailId)) { if (isMailForPassword == true) userInfo.havePassword = true; else userInfo.havePassword = false; AuthenticationService.SendMailToUser(userInfo) .then(function (result) { if (result == LoginConstants.USER_NOT_FOUND) { // alert(LoginMessageConstants.INCORRECT_EMAIL_ID); $rootScope.errorMassage = LoginMessageConstants.INCORRECT_EMAIL_ID; $("#messageModal").modal('show'); } else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); $rootScope.errorMassage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); } else if (result == LoginConstants.MAIL_NOT_SENT) { // alert(LoginMessageConstants.MAIL_NOT_SENT); $rootScope.errorMassage = LoginMessageConstants.MAIL_NOT_SENT; $("#messageModal").modal('show'); } else { if (result.loginId != undefined || result.loginId != "" || result.loginId != null) { var message; if ($('.forgot-sm').length > 0) { $('.forgot-sm').fadeOut(); $('.forgot-sm').modal('hide'); } if ($('.forgot-sm1').length > 0) { $('.forgot-sm1').fadeOut(); $('.forgot-sm1').modal('hide'); } if (isMailForPassword) message = LoginMessageConstants.RESET_PASSWORD; else message = LoginMessageConstants.USERID_SENT_IN_EMAIL //alert(message); $rootScope.errorMassage = message; $("#messageModal").modal('show'); } } }, function (error) { console.log(' Error in authentication = ' + error.statusText); // alert(LoginConstants.ERROR_IN_FECTHING_DETAILS); $rootScope.errorMassage = LoginConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); }); } else { // alert(LoginMessageConstants.INCORRECT_EMAIL_ID); $rootScope.errorMassage = LoginMessageConstants.INCORRECT_EMAIL_ID; $("#messageModal").modal('show'); } } else { //alert(LoginMessageConstants.BLANK_EMAIL_ID); $rootScope.errorMassage = LoginMessageConstants.BLANK_EMAIL_ID; $("#messageModal").modal('show'); } }; $rootScope.closeResetPasswordPopup = function () { $("#passwordReset").fadeOut(); $("#passwordReset").modal('hide'); $location.url("/"); $rootScope.isVisibleResetPass = false; $rootScope.isVisibleLogin = true; } function validateEmail(email) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); } $rootScope.ResetUserPassword = function (userInfo) { var url = $location.url(); if (url.indexOf('?em:') != -1) { var split = url.split('?em:'); userInfo.emailId = split[1]; } if (userInfo.newPassword === userInfo.confirmPassword) { $rootScope.errorMesaage = null; AuthenticationService.ResetUserPassword(userInfo) .then( function (result) { if (result == LoginConstants.USER_NOT_FOUND) { // alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT); $rootScope.errorMassage = LoginMessageConstants.USER_OR_PASSWORD_INCORRECT; $("#messageModal").modal('show'); } else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); $rootScope.errorMassage = LoginConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); } else { if ((result.IsAcknowledged == true) && (result.IsModifiedCountAvailable == true)) { // alert(LoginMessageConstants.PASSWORD_RESET_MESSAGE); $rootScope.errorMassage = LoginMessageConstants.PASSWORD_RESET_MESSAGE; $("#messageModal").modal('show'); $rootScope.isVisibleLogin = true; $rootScope.isVisibleResetPass = false; $location.url("/") ; } } }, function (error) { console.log(' Error in authentication = ' + error.statusText); // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); $rootScope.errorMassage = LoginMessageConstants.ERROR_IN_FECTHING_DETAILS; $("#messageModal").modal('show'); }); } else { $rootScope.errorMesaage = LoginMessageConstants.NEW_AND_OLD_PASSWORD_DONOT_MATCH; $("#messageModal").modal('show'); } } $(document).ready(function () { // getUserDetails(); $(function () { var colpick = $('.demo').each(function () { $(this).minicolors({ control: $(this).attr('data-control') || 'hue', inline: $(this).attr('data-inline') === 'true', letterCase: 'lowercase', opacity: false, change: function (hex, opacity) { $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").removeClass("ActiveDefaultColorAnnotation"); if (!hex) return; if (opacity) hex += ', ' + opacity; try { console.log(hex); $("#text_area").css("color", hex); } catch (e) { } $(this).select(); }, theme: 'bootstrap' }); }); var $inlinehex = $('#inlinecolorhex h3 small'); //alert($inlinehex); $('#inlinecolors').minicolors({ inline: true, theme: 'bootstrap', change: function (hex) { if (!hex) return; $inlinehex.html(hex); } }); }); $(function () { var colpick = $('.drawTextBG').each(function () { $(this).minicolors({ control: $(this).attr('data-control') || 'hue', inline: $(this).attr('data-inline') === 'true', letterCase: 'lowercase', opacity: false, change: function (hex, opacity) { $("#drawTextBGColorpicker .minicolors .minicolors-swatch .minicolors-swatch-color").removeClass("ActiveDefaultColorAnnotation"); if (!hex) return; if (opacity) hex += ', ' + opacity; try { console.log(hex); // $("#text_area").css("background-color", hex); } catch (e) { } $(this).select(); }, theme: 'bootstrap' }); }); var $inlinehex = $('#inlinecolorhex h3 small'); //alert($inlinehex); $('#inlinecolors').minicolors({ inline: true, theme: 'bootstrap', change: function (hex) { if (!hex) return; $inlinehex.html(hex); } }); }); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" }); $("#drawTextBGColorpicker .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#ffffff" }); }); $rootScope.$on("$locationChangeSuccess", function () { $rootScope.HightLightModuleSelection = function (moduleUrl) { var currentRoute = $location.path().substring(1); return moduleUrl === currentRoute ? 'active' : ''; } $("#annotationToolBarOptions").removeClass("disableMenuoption"); if (($location.url() == "/da-body-view")) { $rootScope.disableMenuannotation = " "; $rootScope.disableMenuoption = " "; $rootScope.disableSubMenu = "disableSubMenu"; $rootScope.disableFileMenu = " "; } else if ($location.url() == "/clinical-illustrations-detail") { $rootScope.disableMenuannotation = " "; $rootScope.disableMenuoption = " "; $rootScope.disableSubMenu = "disableSubMenu"; $("#annotationToolBarOptions").removeClass("disableSubMenu"); $rootScope.disableFileMenu = " "; } else if($location.url() == "/clinical-animations-detail") { $rootScope.disableMenuannotation = "disableMenuannotation"; $rootScope.disableMenuoption = " "; $rootScope.disableSubMenu = "disableSubMenu"; $("#annotationToolBarOptions").addClass("disableSubMenu"); $rootScope.disableFileMenu = " "; } else { $("#annotationToolBarOptions").removeClass("disableSubMenu"); $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 = " "; } $rootScope.disableFileMenu = "disableFileMenu"; } }); //jspanel functionality.. $rootScope.getSelectedModuleId = function (selectedModuleId) { setTimeout(function () { $(".sidebar").mCustomScrollbar("scrollTo", $("#" + selectedModuleId)); }, 300); } $rootScope.openParent = function (slug) { 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 $rootScope.isAnnotatiomToolBarPopupActive = true; $rootScope.isAnnotatiomToolBarPopupClosed = false; $rootScope.isAnnotaionToolBarDrawingModeActive = false; 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'); $("#annotationpainteraser").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'); $("#annotationpainteraser").removeAttr('disabled', 'disabled'); } // document.getElementById('modelbackground').style.display = "block"; // document.getElementById('modeleditstyle').style.display = "block"; } if ($rootScope.MenuModuleName == "CA") { $("#annotationpaintbrushsize").attr("href", "#"); $("#annotationpainteraser").attr("href", "#"); $("#annotationpainteraser").attr('disabled', 'disabled'); $("#annotationpainteraser").css('pointer-events', 'none'); } else { $("#annotationpaintbrushsize").attr("href", "#canvasPaint"); $("#annotationpainteraser").attr("href", "#canvasPaint"); $("#annotationpainteraser").removeAttr('disabled', 'disabled'); $("#annotationpainteraser").css('pointer-events', 'auto'); } $("#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) } ) } if ($("#transparencyScale").css("display") == "block") { $rootScope.switchToTransparencycanvas(); } } $rootScope.CloseAnnotationTool = function () { console.log('close'); $rootScope.isAnnotatiomToolBarPopupActive = false; $rootScope.isAnnotatiomToolBarPopupClosed = true; $("#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 = false; if ($("#transparencyScale").css("display") == "block") { $rootScope.switchToTransparencycanvas(); } else { $rootScope.switchCanvas(); } $rootScope.shapeType = ''; } $rootScope.CIAnotationIdentifyModeOff = false; $rootScope.OnIdentifyClick = function () { $("#OnIdentify").addClass("annotationtoolbartab"); $("#DrawMode").removeClass("annotationtoolbartab"); if ($rootScope.CIAnotationIdentifyModeOff == true) { $('.btnCursor').removeClass('activebtncolor'); } else { $('.btnCursor').removeClass('activebtncolor'); } $("#annotationpaintbrushsize").removeClass("activebtncolor"); $("#annotationpainteraser").removeClass("activebtncolor"); $rootScope.isAnnotaionToolBarDrawingModeActive = false; $rootScope.switchCanvas(); if ($("#transparencyScale").css("display") == "block") { $rootScope.switchToTransparencycanvas(); } } $rootScope.switchToTransparencycanvas = function () { if ($rootScope.isModestyCanvasVisible == true) { var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']"); if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { for (var j = 0; j < modestyTransCanvases.length; j++) { var ctx = document.getElementById(modestyTransCanvases[j].id); if (ctx.style.visibility == "visible") { if ($("#OnIdentify").hasClass("annotationtoolbartab")) { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); var TransCanvasZindex = ctx.style.zIndex; var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex); MaxZindexVal = MaxZindexVal + 1; $("#canvas").css("z-index", MaxZindexVal); $('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal); } else { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); var TransCanvasZindex = ctx.style.zIndex; var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex); MaxZindexVal = parseInt(MaxZindexVal + 1); if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) { $("#canvasPaint").css("z-index", MaxZindexVal); } else { $("#canvas").css("z-index", MaxZindexVal); } } } else { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); drawCanvasZindex = parseInt(drawCanvasZindex) + 1; paintCanvasZindex = parseInt(paintCanvasZindex) + 1; if (drawCanvasZindex > paintCanvasZindex) { $(".ui-wrapper").css("z-index", drawCanvasZindex); $("#canvas").css("z-index", drawCanvasZindex); $rootScope.UIWrapperZIndex = drawCanvasZindex; } else { $(".ui-wrapper").css("z-index", paintCanvasZindex); $("#canvas").css("z-index", paintCanvasZindex); $rootScope.UIWrapperZIndex = paintCanvasZindex; } } } } } else { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); drawCanvasZindex = parseInt(drawCanvasZindex) + 1; paintCanvasZindex = parseInt(paintCanvasZindex) + 1; if (drawCanvasZindex > paintCanvasZindex) { $(".ui-wrapper").css("z-index", drawCanvasZindex); $("#canvas").css("z-index", drawCanvasZindex); $rootScope.UIWrapperZIndex = drawCanvasZindex; } else { $(".ui-wrapper").css("z-index", paintCanvasZindex); $("#canvas").css("z-index", paintCanvasZindex); $rootScope.UIWrapperZIndex = paintCanvasZindex; } } } $rootScope.DrawingMode = function () { //Annotation History $rootScope.isAnnotaionToolBarDrawingModeActive = true; $("#OnIdentify").removeClass("annotationtoolbartab"); $("#DrawMode").addClass("annotationtoolbartab"); $('.btnCursor').addClass('activebtncolor'); $rootScope.switchCanvas(); $("#annotationpaintbrushsize").removeClass("activebtncolor"); $("#annotationpainteraser").removeClass("activebtncolor"); $rootScope.isEraseToolSelected = false; } // 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"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-line").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvas(); $rootScope.shapeType = "Line"; $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.DrawPin = function (e) { $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-pin").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvas(); $rootScope.setListManagerZindex = true; $rootScope.shapeType = "Pin"; $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.Cursor = function () { $rootScope.switchCanvas(); $rootScope.shapeType = "cursor"; $(".btn-annotation").removeClass("activebtncolor"); // $("#" + e.currentTarget.id).removeClass("activebtncolor"); $('.btnCursor').addClass('activebtncolor'); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.DrawRectangle = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-rectangle").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvas(); $rootScope.shapeType = "Rectangle"; $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.paintBrush = function () { $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-brush").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.isAnnotaionToolBarDrawingModeActive = true; 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 { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); if ((document.getElementById('fill-option').checked == false) && ($rootScope.isShapeSyleOkBtnClicked == true)) { $rootScope.switchCanvas(); } else if ($("#editstylebackgroundcolor span.minicolors-swatch-color").css('background-color') == "rgba(0, 0, 0, 0)") { // we are switching canvas from paint to draw to prevent paint because it does not take transparent color and we need control default black color for the case where user has unchecked fill option from Edit Shape Style window $rootScope.switchCanvas(); } else { $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(); } } } $rootScope.switchCanvasToPaintCanvas = function (e) { if ($rootScope.isModestyCanvasVisible == true) { var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']"); if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { for (var j = 0; j < modestyTransCanvases.length; j++) { var ctx = document.getElementById(modestyTransCanvases[j].id); if (ctx.style.visibility == "visible") { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); var TransCanvasZindex = ctx.style.zIndex; var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex); MaxZindexVal = MaxZindexVal + 1; if (($("#canvasPaint").css("display") == "block") && ($("#canvas").css("display") == "block")) { if ($("#OnIdentify").hasClass("annotationtoolbartab")) { $("#canvas").css("z-index", MaxZindexVal); $('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal); } else { if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) { $("#canvasPaint").css("z-index", MaxZindexVal); } else { $("#canvas").css("z-index", MaxZindexVal); } } } } else { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex); MaxZindexVal = parseInt(MaxZindexVal + 1); if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) { $("#canvasPaint").css("z-index", MaxZindexVal); } else { $("#canvas").css("z-index", MaxZindexVal); } } } } } else { 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"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-circle").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvas(); $rootScope.shapeType = "Circle"; $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.DrawArrow = function (e) { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-arrow").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvas(); $rootScope.shapeType = "Arrow"; $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.DrawText = function () { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-Text").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvas(); $rootScope.shapeType = "TextArea"; $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.DrawPolygon = function () { $rootScope.setListManagerZindex = true; $("#canvasPaint").css("display", "block"); $("#canvas").css("display", "block"); $rootScope.shapeType = "DrawPolygon"; $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.isAnnotaionToolBarDrawingModeActive = true; } $rootScope.switchCanvas = function () { if ($rootScope.isModestyCanvasVisible == true) { var modestyTransCanvases = $("canvas[id*='modestyTransCanavs']"); if (modestyTransCanvases != null || modestyTransCanvases != undefined && modestyTransCanvases.length > 0) { for (var j = 0; j < modestyTransCanvases.length; j++) { var ctx = document.getElementById(modestyTransCanvases[j].id); if (ctx.style.visibility == "visible") { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); var TransCanvasZindex = ctx.style.zIndex; var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex); MaxZindexVal = MaxZindexVal + 1; if ($("#OnIdentify").hasClass("annotationtoolbartab")) { $("#canvas").css("z-index", MaxZindexVal); $('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal); } else { if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) { $("#canvasPaint").css("z-index", MaxZindexVal); } else { $("#canvas").css("z-index", MaxZindexVal); } } } else { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex); MaxZindexVal = parseInt(MaxZindexVal + 1); if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) { $("#canvasPaint").css("z-index", MaxZindexVal); } else { $("#canvas").css("z-index", MaxZindexVal); } } } } } else { var drawCanvasZindex = $("#canvas").css("z-index"); var paintCanvasZindex = $("#canvasPaint").css("z-index"); if (drawCanvasZindex > paintCanvasZindex) { paintCanvasZindex = parseInt(drawCanvasZindex) + 1; } else { paintCanvasZindex = parseInt(paintCanvasZindex) + 1; } $('#canvas').css("z-index", paintCanvasZindex); } } $rootScope.EraseDrawing = function () { $rootScope.isAnnotaionToolBarDrawingModeActive = true; $('.btnCursor').removeClass('activebtncolor'); $(".btn-annotation").removeClass("activebtncolor"); $(".btn-annotation-erase").addClass("activebtncolor"); $("#OnIdentify").removeClass('annotationtoolbartab'); $("#DrawMode").addClass('annotationtoolbartab'); $rootScope.switchCanvasToPaintCanvas(); var btneraseBrushSizeValue = $("#btnBrushSize").val(); $('#canvasPaint').sketch(); $rootScope.eraseshapeSize = parseInt(btneraseBrushSizeValue); $("#annotationpainteraser").attr("data-size", $rootScope.eraseshapeSize); return $.sketch.tools.eraser = { onEvent: function (e) { return $.sketch.tools.marker.onEvent.call(this, e); }, draw: function (action) { var oldcomposite; oldcomposite = this.context.globalCompositeOperation; this.context.globalCompositeOperation = "destination-out"; action.color = "#000000"; $.sketch.tools.marker.draw.call(this, action); return this.context.globalCompositeOperation = oldcomposite; } } } $rootScope.isShapeSyleOkBtnClicked = false; $rootScope.setPropertiesForShapes = function (id) { isfilloptionChecked = document.getElementById('fill-option').checked; isOutlineOptionChecked = document.getElementById('Outline-Option').checked; $rootScope.isShapeSyleOkBtnClicked = true; if ($("#annotationpaintbrushsize").hasClass('activebtncolor')) { $("#annotationpaintbrushsize").removeClass('activebtncolor') $rootScope.switchCanvas(); } if ($("#annotationpainteraser").hasClass('activebtncolor')) { $("#annotationpainteraser").removeClass('activebtncolor') $rootScope.switchCanvas(); } 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); document.getElementById("editStyleForm").reset(); isOutlineOptionChecked = document.getElementById('Outline-Option').checked; isfilloptionChecked = document.getElementById('fill-option').checked; if (isOutlineOptionChecked == true) { $(".setEnableDisableForEditShapeStyle").css({ "opacity": "1" }); $("#borderWidthCanvasElement").css({ "pointer-events": "auto" }); $("#outlineColor").css({ "pointer-events": "auto" }); } else { $(".setEnableDisableForEditShapeStyle").css({ "opacity": ".5" }); $("#borderWidthCanvasElement").css({ "pointer-events": "none" }); $("#outlineColor").css({ "pointer-events": "none" }); } if (isfilloptionChecked == true) { $(".enableDisableOpacity label").css({ "cursor": "pointer" }); $(".enableDisableOpacity").css({ "opacity": "1" }); $("#edit-slider-3").css({ "pointer-events": "auto" }); $("#edit-slider-4").css({ "pointer-events": "auto" }); $("#editstylebackgroundcolor").css({ "pointer-events": "auto" }); } else { $(".enableDisableOpacity label").css({ "cursor": "pointer" }); $(".enableDisableOpacity").css({ "opacity": ".5" }); $("#edit-slider-3").css({ "pointer-events": "none" }); $("#edit-slider-4").css({ "pointer-events": "none" }); $("#editstylebackgroundcolor").css({ "pointer-events": "none" }); } } else { document.getElementById('fill-option').checked = isfilloptionChecked; document.getElementById('Outline-Option').checked = isOutlineOptionChecked; if (isfilloptionChecked == true) { $(".enableDisableOpacity label").css({ "cursor": "pointer" }); $(".enableDisableOpacity").css({ "opacity": "1" }); $("#edit-slider-3").css({ "pointer-events": "auto" }); $("#edit-slider-4").css({ "pointer-events": "auto" }); $("#editstylebackgroundcolor").css({ "pointer-events": "auto" }); } else { $(".enableDisableOpacity label").css({ "cursor": "pointer" }); $(".enableDisableOpacity").css({ "opacity": ".5" }); $("#edit-slider-3").css({ "pointer-events": "none" }); $("#edit-slider-4").css({ "pointer-events": "none" }); $("#editstylebackgroundcolor").css({ "pointer-events": "none" }); } if (isOutlineOptionChecked == true) { $(".setEnableDisableForEditShapeStyle").css({ "opacity": "1" }); $("#borderWidthCanvasElement").css({ "pointer-events": "auto" }); $("#outlineColor").css({ "pointer-events": "auto" }); } else { $(".setEnableDisableForEditShapeStyle").css({ "opacity": ".5" }); $("#borderWidthCanvasElement").css({ "pointer-events": "none" }); $("#outlineColor").css({ "pointer-events": "none" }); } 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: Math.abs(x - offsetX1), height: Math.abs(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), //added abs width: Math.abs(x - offsetX1), height: Math.abs(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: Math.abs($rootScope.x - $rootScope.offsetX1), height: Math.abs($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) { if ($rootScope.isAnnotatiomToolBarPopupClosed == false) { 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; } if ($rootScope.isAnnotatiomToolBarPopupClosed == false) { 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("
"); $rootScope.Annotationangle(); break; case "Pin": $(".pin").remove(); $rootScope.isPinPreviewCompleted = true; $("#canvasDiv").append("
"); $rootScope.Annotationangle(); break; case "Circle": $(".circle").remove(); $rootScope.isCirclePreviewCompleted = true; $("#canvasDiv").append("
"); break; case "Rectangle": $(".rectangle").remove(); $rootScope.isRectanglePreviewCompleted = true; $("#canvasDiv").append("
"); break; case "TextArea": $(".textarea").remove(); $rootScope.isTextAreaPreviewCompleted = true; $("#canvasDiv").append("
"); break; } } $rootScope.Annotationangle = function (event) { var dy = $rootScope.MouseMoveYAxis - $rootScope.offsetY1; var dx = $rootScope.MouseMoveXAxis - $rootScope.offsetX1; var theta = 0; if (dx < 0) { theta = Math.atan(dy / dx) * (180 / Math.PI); theta = theta + 180; } else if (dy < 0) { theta = Math.atan(dy / dx) * (180 / Math.PI); theta = theta + 360; } else { theta = Math.atan(dy / dx) * (180 / Math.PI); } var dottedLineWidth = Math.sqrt(($rootScope.offsetX1 - $rootScope.MouseMoveXAxis) * ($rootScope.offsetX1 - $rootScope.MouseMoveXAxis) + ($rootScope.offsetY1 - $rootScope.MouseMoveYAxis) * ($rootScope.offsetY1 - $rootScope.MouseMoveYAxis)); switch ($rootScope.shapeType) { case "Line": $('.line').css({ 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%', 'width': dottedLineWidth + 'px' }); break; case "Arrow": $('.arrow').css({ 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%', 'width': dottedLineWidth + 'px' }); break; case "Pin": $('.pin').css({ 'transform': 'rotate(' + theta + 'deg)', '-moz-transform': 'rotate(' + theta + 'deg)', '-webkit-transform': 'rotate(' + theta + 'deg)', 'transform-origin': '0% 0%', 'width': dottedLineWidth + 'px' }); break; } } ///----- $rootScope.saveText = function () { document.getElementById('modelbackground').style.display = "none"; $rootScope.selectedBGColorForTextArea = $("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color'); // this part will work first time when save button will be clicked if ($rootScope.IsTextAlreadySave == false) { // getting textarea style properties $rootScope.fontSizes = $("#text_area").css("font-size"); $rootScope.fontWeight = $("#text_area").css("font-weight"); $rootScope.fontStyle = $("#text_area").css("font-style"); $rootScope.textAlignmt = $("#text_area").css("text-align"); $rootScope.fontColor = $("#text_area").css("color"); $rootScope.fontFamily = $("#text_area").css("font-family"); $rootScope.underlineText = $("#text_area").css("text-decoration"); $rootScope.textArea = $("#text_area").val(); // deleting previous text area $("#canvas").removeLayer($rootScope.TextID).drawLayers(); $("#canvas").removeLayer($rootScope.TextAreaRectID).drawLayers(); // Text After Saving in Rectangle $rootScope.resetTextRect = $rootScope.ObjectIndex++; $('#canvas').drawRect({ name: 'TextArea1_' + $rootScope.resetTextRect, layer: true, draggable: true, groups: ['TextAreaNew_' + $rootScope.resetTextRect], dragGroups: ['TextAreaNew_' + $rootScope.resetTextRect], opacity: $rootScope.shapestyleOpacity, strokeStyle: $rootScope.shapestyleborderColor, strokeWidth: $rootScope.shapestyleborderWidth, fillStyle: $rootScope.selectedBGColorForTextArea, fromCenter: false, x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y, width: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width), height: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height), resizeFromCenter: false, add: function (layer) { var TextAreaLayerName = layer.name; var TextAreaLayerNameAftrSplit = TextAreaLayerName.split("_"); $rootScope.postFixLayerNumber = TextAreaLayerNameAftrSplit[1]; }, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.shapeTypeText = "textAreaRect"; var layerName = layer.name; var splitedName = layerName.split("_"); var textValName = "TextAreaNew_"; var concatinateResult = textValName.concat(splitedName[1]); $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult }); $('#canvas').setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 7, height: 7, cornerRadius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, dblclick: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.isTextAreaClosedButtonActive = false; $rootScope.IsTextAlreadySave = true; var _rectLayerOnSave = layer.name; var _rectLayerOnSaveSplit = _rectLayerOnSave.split("_"); var TextAreaRectName = "TextAreaNew_"; var TextAreaRectNameConcatenated = TextAreaRectName.concat(_rectLayerOnSaveSplit[1]); $rootScope.layerNameArr = layer.name; $rootScope.rectTextArr = TextAreaRectNameConcatenated; $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y }); for (var i = 0; i <= $rootScope.TextPropertyArray.length - 1; i++) { if ($rootScope.TextPropertyArray[i].layerName == TextAreaRectNameConcatenated) { var textArrVal = $rootScope.TextPropertyArray[i].Rect_Text; $("#text_area").val(textArrVal); var fontStyleProp = $rootScope.TextPropertyArray[i].FontStyle; var fontWeightProp = fontStyleProp.split(" "); $("#text_area").css("font-size", $rootScope.TextPropertyArray[i].FontSize); $("#text_area").css("font-weight", fontWeightProp[0]); $("#text_area").css("font-style", fontWeightProp[1]); $("#text_area").css("text-align", $rootScope.TextPropertyArray[i].Align); $("#text_area").css("color", $rootScope.TextPropertyArray[i].FontColor); $("#text_area").css("font-family", $rootScope.TextPropertyArray[i].FontFamily); $("#text_area").css("text-decoration", $rootScope.TextPropertyArray[i].TextDecoration); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": $rootScope.TextPropertyArray[i].FontColor }); var CurrentFontFamily = $rootScope.TextPropertyArray[i].FontFamily; // alert(CurrentFontFamily); // CurrentFontFamily = CurrentFontFamily.replace(/'/g, ""); var CurrentFontSize = parseInt($rootScope.TextPropertyArray[i].FontSize); $("#selected-font-family option[value=" + CurrentFontFamily + "]").prop('selected', true); $("#selected-font-size option[value=" + CurrentFontSize + "]").prop('selected', true); CurrentFontFamily = ''; CurrentFontSize = ''; if ($rootScope.TextPropertyArray[i].TextDecoration == "underline") { $("#text-underline").addClass("ActiveFormattingButtonClass"); } else { $("#text-underline").removeClass("ActiveFormattingButtonClass"); } //adding text font weight active class in text edit pop-up if (fontWeightProp[0] == 700) { $("#text-bold").addClass("ActiveFormattingButtonClass"); } else { $("#text-bold").removeClass("ActiveFormattingButtonClass"); } //adding text font style active class in text edit pop-up if (fontWeightProp[1] == "italic") { $("#text-italic").addClass("ActiveFormattingButtonClass"); } else { $("#text-italic").removeClass("ActiveFormattingButtonClass"); } //adding text alignment active class in text edit pop-up if ($rootScope.TextPropertyArray[i].Align == "left") { $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass") $("#text-left").addClass("ActiveFormattingButtonClass"); } else if ($rootScope.TextPropertyArray[i].Align == "right") { $("#text-center").removeClass("ActiveFormattingButtonClass") $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").addClass("ActiveFormattingButtonClass"); } else if ($rootScope.TextPropertyArray[i].Align == "center") { $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").addClass("ActiveFormattingButtonClass"); } } else { // alert("no"); } } // _rectLayerOnSaveSplitInt = ''; textArrVal = ''; $("#annotationTextModal").css("padding-right", "0px"); document.getElementById('modelbackground').style.display = "block"; $("#annotationTextModal").modal("toggle"); // $("#selected-font-family").val(CurrentFontFamily); // $("#selected-font-size").val(CurrentFontSize); } 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: 7, height: 7, cornerRadius: 3, click: function () { $rootScope.isTextAReaRectangleClicked = true; } } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, change: function (layer) { if ($rootScope.isTextAReaRectangleClicked == true) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { console.log(layer.x + " " + layer.y); console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize); $rootScope.isTextAReaRectangleClicked = false; //if ((layer.x > $rootScope.textXAxisAftrResize) && (layer.y > $rootScope.textYAxisAftrResize) || (layer.x == $rootScope.textXAxisAftrResize) && (layer.y > $rootScope.textYAxisAftrResize) || (layer.x > $rootScope.textXAxisAftrResize) && (layer.y == $rootScope.textYAxisAftrResize)) { var CangedTextAreaName = 'TextAreaNew_' + $rootScope.postFixLayerNumber; $('#canvas').setLayer(CangedTextAreaName, { x: layer.x, y: layer.y }); //} $rootScope.textXAxisAftrResize = layer.x; $rootScope.textYAxisAftrResize = layer.y; } } } }).drawText({ layer: true, draggable: true, name: 'TextAreaNew_' + $rootScope.resetTextRect, groups: ['TextAreaNew_' + $rootScope.resetTextRect], dragGroups: ['TextAreaNew_' + $rootScope.resetTextRect], fillStyle: $rootScope.fontColor, fontStyle: $rootScope.fontWeight + " " + $rootScope.fontStyle, fontSize: $rootScope.fontSizes, fromCenter: false, fontFamily: $rootScope.fontFamily, align: $rootScope.textAlignmt, strokeWidth: 0, text: $rootScope.textArea, x: ($rootScope.rectDimension[$rootScope.rectDimension.length - 1].x), y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y, maxWidth: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width), maxHeight: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height), add: function (layer) { // console.log(layer.x + " " + layer.y); $rootScope.textXAxisAftrResize = layer.x; $rootScope.textYAxisAftrResize = layer.y; //$rootScope.TextPropertyArray.push({ Text1: '', Align: '', FontColor: '', FontSize: '', FontStyle: '', FontFamily: '' }); $rootScope.TextPropertyArray.push({ layerName: layer.name, Rect_Text: layer.text, Align: layer.align, FontColor: layer.fillStyle, FontSize: layer.fontSize, FontStyle: layer.fontStyle, FontFamily: layer.fontFamily, TextDecoration: $rootScope.underlineText }); } }); $("#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); // $("#selected-font-family option:eq(0)").prop('selected', true); // $("#selected-font-size option:eq(0)").prop('selected', true); // $("#selected-font-family option[value='Arial']").prop('selected', true); // $("#selected-font-size option[value=14]").prop('selected', true); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" }); $("#text-italic").removeClass("ActiveFormattingButtonClass"); $("#text-bold").removeClass("ActiveFormattingButtonClass"); $("#text-underline").removeClass("ActiveFormattingButtonClass"); $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass"); } // this part will work second time when save button will be clicked else { // getting textarea style properties var _modifiedText = $("#text_area").val(); var _modifiedFontSize = $("#text_area").css("font-size"); var _modifiedFontWeight = $("#text_area").css("font-weight"); var _modifiedFontStyle = $("#text_area").css("font-style"); var _modifiedTextAlign = $("#text_area").css("text-align"); var _modifiedFontColor = $("#text_area").css("color"); var _modifiedFontFamily = $("#text_area").css("font-family"); var _modifiedFontDecoration = $("#text_area").css("text-decoration"); // deleting previous textarea $("#canvas").removeLayer($rootScope.layerNameArr).drawLayers(); $("#canvas").removeLayer($rootScope.rectTextArr).drawLayers(); $rootScope.resetTextRectSave = $rootScope.ObjectIndexSave++; $rootScope.resetTextSave = $rootScope.ObjectIndexSave++; // generating new text area // $('#canvas') // Draw rect as wide as the text $('#canvas').drawRect({ name: 'TextAreaAfterEditRect_' + $rootScope.resetTextSave, layer: true, draggable: true, groups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave], dragGroups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave], opacity: $rootScope.shapestyleOpacity, fromCenter: false, strokeStyle: $rootScope.shapestyleborderColor, strokeWidth: $rootScope.shapestyleborderWidth, fillStyle: $rootScope.selectedBGColorForTextArea, x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y, width: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width), height: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height), resizeFromCenter: false, add: function (layer) { var TextAreaLayerName = layer.name; var TextAreaLayerNameAftrSplit = TextAreaLayerName.split("_"); $rootScope.postFixLayerNumberAftrEdit = TextAreaLayerNameAftrSplit[1]; }, click: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.shapeTypeText = "textAreaRect"; var layerName = layer.name; var splitedName = layerName.split("_"); var textValName = "TextAreaAfterEdit_"; var concatinateResult = textValName.concat(splitedName[1]); $rootScope.canvasLayerNameCollection = []; $rootScope.canvasLayerNameCollection.push({ textareaRectangle: layer.name, textareaString: concatinateResult }); $('#canvas').setLayer(layer.name, { handle: { type: 'rectangle', fillStyle: '#fff', strokeStyle: '#c33', strokeWidth: 2, width: 7, height: 7, cornerRadius: 3 } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, dblclick: function (layer) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { //jcanvas property layer.draggable = true; $rootScope.isTextAreaClosedButtonActive = false; $rootScope.IsTextAlreadySave = true; var _rectLayerOnSave = layer.name; var _rectLayerOnSaveSplit = _rectLayerOnSave.split("_"); var RectNameAfterEdit = "TextAreaAfterEdit_"; var RectNameAfterEditResult = RectNameAfterEdit.concat(_rectLayerOnSaveSplit[1]); $rootScope.modifySavedTextIndexNumber = _rectLayerOnSaveSplit[1]; $rootScope.layerNameArr = layer.name; $rootScope.rectTextArr = RectNameAfterEditResult; $rootScope.rectDimension.push({ width: layer.width, height: layer.height, x: layer.x, y: layer.y }); $("#text_area").val(_modifiedText); $("#text_area").css("font-size", _modifiedFontSize); $("#text_area").css("font-weight", _modifiedFontWeight); $("#text_area").css("font-style", _modifiedFontStyle); $("#text_area").css("text-align", _modifiedTextAlign); $("#text_area").css("color", _modifiedFontColor); $("#text_area").css("font-family", _modifiedFontFamily); $("#text_area").css("text-decoration", _modifiedFontDecoration); $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": _modifiedFontColor }); // $(".ActiveDefaultColorAnnotation").css({ "background-color": _modifiedFontColor + "!important" }); // $("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").addClass("ActiveDefaultColorAnnotation"); //khushbu var CurrentFontFamily = _modifiedFontFamily; // alert(CurrentFontFamily); // CurrentFontFamily = CurrentFontFamily.replace(/'/g, ""); var CurrentFontSize = parseInt(_modifiedFontSize); $("#selected-font-family option[value=" + CurrentFontFamily + "]").prop('selected', true); $("#selected-font-size option[value=" + CurrentFontSize + "]").prop('selected', true); CurrentFontFamily = ''; CurrentFontSize = ''; //adding text text decoration active class in text edit pop-up if (_modifiedFontDecoration == "underline") { $("#text-underline").addClass("ActiveFormattingButtonClass"); } else { $("#text-underline").removeClass("ActiveFormattingButtonClass"); } //adding text font weight active class in text edit pop-up if (_modifiedFontWeight == 700) { $("#text-bold").addClass("ActiveFormattingButtonClass"); } else { $("#text-bold").removeClass("ActiveFormattingButtonClass"); } //adding text font style active class in text edit pop-up if (_modifiedFontStyle == "italic") { $("#text-italic").addClass("ActiveFormattingButtonClass"); } else { $("#text-italic").removeClass("ActiveFormattingButtonClass"); } //adding text alignment active class in text edit pop-up if (_modifiedTextAlign == "left") { $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").removeClass("ActiveFormattingButtonClass") $("#text-left").addClass("ActiveFormattingButtonClass"); } else if (_modifiedTextAlign == "right") { $("#text-center").removeClass("ActiveFormattingButtonClass") $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").addClass("ActiveFormattingButtonClass"); } else if (_modifiedTextAlign == "center") { $("#text-left").removeClass("ActiveFormattingButtonClass"); $("#text-right").removeClass("ActiveFormattingButtonClass"); $("#text-center").addClass("ActiveFormattingButtonClass"); } document.getElementById('modelbackground').style.display = "block"; $("#annotationTextModal").modal("toggle"); } 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; } $rootScope.RectXAxisAftrResize = layer.x; $rootScope.RectYAxisAftrResize = layer.y; }, 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: 7, height: 7, cornerRadius: 3, click: function () { $rootScope.isTextAReaRectangleClickedAftrEdit = true; } } }).drawLayers(); } else { //jcanvas property layer.draggable = false; } }, change: function (layer) { if ($rootScope.isTextAReaRectangleClickedAftrEdit == true) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) { console.log(layer.x + " " + layer.y); console.log($rootScope.textXAxisAftrResize + " " + $rootScope.textYAxisAftrResize); $rootScope.isTextAReaRectangleClickedAftrEdit = false; //if ((layer.x > $rootScope.textXAxisAftrResize) && (layer.y > $rootScope.textYAxisAftrResize) || (layer.x == $rootScope.textXAxisAftrResize) && (layer.y > $rootScope.textYAxisAftrResize) || (layer.x > $rootScope.textXAxisAftrResize) && (layer.y == $rootScope.textYAxisAftrResize)) { var CangedTextAreaName = 'TextAreaAfterEdit_' + $rootScope.postFixLayerNumberAftrEdit; $('#canvas').setLayer(CangedTextAreaName, { x: layer.x, y: layer.y }); //} $rootScope.editTextXAxisAftrResize = layer.x; $rootScope.editTextYAxisAftrResize = layer.y; } } } }).drawText({ layer: true, draggable: true, name: 'TextAreaAfterEdit_' + $rootScope.resetTextSave, groups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave], dragGroups: ['TextAreaAfterEdit_' + $rootScope.resetTextSave], fillStyle: _modifiedFontColor, fontStyle: _modifiedFontWeight + " " + _modifiedFontStyle, fontSize: _modifiedFontSize, fontFamily: _modifiedFontFamily, align: _modifiedTextAlign, strokeWidth: 0, fromCenter: false, text: _modifiedText, x: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].x, y: $rootScope.rectDimension[$rootScope.rectDimension.length - 1].y, maxWidth: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].width), maxHeight: Math.abs($rootScope.rectDimension[$rootScope.rectDimension.length - 1].height), add: function (layer) { // console.log(layer.x + " " + layer.y); $rootScope.editTextXAxisAftrResize = layer.x; $rootScope.editTextYAxisAftrResize = layer.y; } }); } } //---- $rootScope.onDrawingCanvasClick = function (event) { $rootScope.clicked = true; // OnPaintCanvasMouseDown(event); var annotationCanvas = document.getElementById('canvas'); if (annotationCanvas != null || annotationCanvas != undefined) { annotationCanvas.addEventListener('mousedown', $rootScope.OnPaintCanvasMouseDown, false); annotationCanvas.addEventListener('mouseup', $rootScope.OnPaintCanvasMouseUp, false); } // alert("doclick"); // annotation history if (event != undefined) { if ($rootScope.isAnnotaionToolBarDrawingModeActive == false) { $rootScope.getAnnotationTextBasedOnSelectedBodyRegion(event); } } }; $(document).keydown(function (event) { // predefined function for detecting keyboard key if (event.which == 46) { if ($rootScope.shapeTypePin == "Pin") { $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].pinName).drawLayers(); $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].ArcName).drawLayers(); $rootScope.shapeTypePin = ""; } else if ($rootScope.shapeTypeText == "textAreaRect") { $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].textareaRectangle).drawLayers(); $("#canvas").removeLayer($rootScope.canvasLayerNameCollection[0].textareaString).drawLayers(); $rootScope.shapeTypeText = ""; } else { $("#canvas").removeLayer($rootScope.canvasLayerNameCollection).drawLayers(); } } }); $rootScope.closeModal = function () { document.getElementById('modelbackground').style.display = "none"; } //-- End ---------------------------- $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; canvasContext.strokeStyle = 'red'; canvasContext.beginPath(); 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.disableAnnotationTB = false; $rootScope.disableAnnotationTBFn = function () { $rootScope.disableAnnotationTB = true; } //list manager function //list manager function $rootScope.disableAnnotationtoolOnListManager = false; $rootScope.ShowListManager = function () { $rootScope.switchCanvas(); $("#annotationpaintbrushsize").attr("href", "#"); $("#annotationpainteraser").attr("href", "#"); console.log('ShowListManager') $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'); $("#annotationpainteraser").attr('disabled', 'disabled'); $("#annotationpaintbrushsize").css('pointer-events', 'none'); $("#annotationpainteraser").css('pointer-events', 'none'); $rootScope.isLoading = true; $('#spinner').css('visibility', 'visible'); $('#listManager').css('display', 'block'); $("#listManager").css("visibility", "visible"); $('#listManager').draggable(); $rootScope.islistManagerEventAlredayDispachted = true; $rootScope.$broadcast('listManagerEvent', true); if ($rootScope.selectedBodySystemName == undefined && $rootScope.slectedActualTermNumber == undefined) { $('#termList option[selected="selected"]').prop("selected", false); $('#termList option[value="' + $rootScope.searchSelectedText + '"]').prop("selected", true); $("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); $('#termList option[value="' + $rootScope.searchSelectedText + '"]').css({ "background-color": "#3399FF", "color": "#ffffff" }); } else { if ($rootScope.selectedBodySystemId == undefined) { $rootScope.selectedBodySystemId = 0; $rootScope.refreshTermListOnSystemSelection($rootScope.selectedBodySystemId); } else { $rootScope.refreshTermListOnSystemSelection($rootScope.selectedBodySystemId); } $('#bodySystems option[selected="selected"]').prop("selected", false); $('#bodySystems option[value="' + $rootScope.selectedBodySystemName + '"]').prop("selected", true); // $('#termList option[selected="selected"]').prop("selected", false); // $('#termList option[value="' + $rootScope.SelectedTermList + '"]').prop("selected", true); //$("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" }); //$('#termList option[value="' + $rootScope.SelectedTermList + '"]').css({ "background-color": "#3399FF", "color": "#ffffff" }); } $("#optionsListManagerTab").addClass("active"); } $rootScope.CloseListManager = function () { $("#btnTranparency").removeAttr('disabled', 'disabled'); $("#optionsListManagerTab").removeClass("active"); console.log('close'); $rootScope.disableAnnotationtoolOnListManager = false; if ($rootScope.MenuModuleName == "DA") { $("#annotationpaintbrushsize").attr("href", "#canvasPaint"); $("#annotationpainteraser").attr("href", "#canvasPaint"); if ($rootScope.disableAnnotationtoolOnListManager == false) { $('#AnnotaionPopupDiv').find('a,input, textarea, button, select,img,div').removeAttr('disabled', 'disabled'); $('#slider-range-min-2').slider('enable'); $("#annotationpaintbrushsize").removeAttr('disabled', 'disabled'); $("#annotationpainteraser").removeAttr('disabled', 'disabled'); $("#annotationpaintbrushsize").css('pointer-events', 'auto'); $("#annotationpainteraser").css('pointer-events', 'auto'); $rootScope.switchCanvasToPaintCanvas(); } } $('#listManager').css('display', 'none'); $("#listManager").css("visibility", "hidden"); $rootScope.isLoading = false; $('#spinner').css('visibility', 'hidden'); //$('#spinner').css('display', 'none'); // $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) { } } $rootScope.prevId = ""; } 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) { } } //setrtings $rootScope.SetSettingActiveTab = function (tabToSet) { $rootScope.SettingsTab = tabToSet; }; $rootScope.loadsettings = function () { //1. For now we are by default opening DA settings tab $rootScope.SettingsTab = 3; //2. var curentEthnicity = localStorage.getItem("globalEthnicity"); if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) { $rootScope.globalSetting.ethnicity = curentEthnicity; } else { localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity); } var curentmodesty = localStorage.getItem("globalModesty"); if (typeof (curentmodesty) !== "undefined" && curentmodesty !== null) { $rootScope.globalSetting.modesty = curentmodesty } else { localStorage.setItem("globalModesty", $rootScope.globalSetting.modesty); } //3. $rootScope.setModestySettings($rootScope.globalSetting.modesty); //4. $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity); }; $rootScope.setModestySettings = function (currentmodsetting) { if (currentmodsetting == 'Y') { $rootScope.isModestyOn = true; $rootScope.isModestyOff = false; } else { $rootScope.isModestyOn = false; $rootScope.isModestyOff = true; } } $rootScope.setEthncitySettings = function (currentEthncitysetting) { // this code is used for maintaing the currently selected Ethencity. if (currentEthncitysetting == 'L') { $("#btnEthnicA").addClass("skindefault"); if ($("#btnEthnicB").hasClass("skindefault")) { $("#btnEthnicB").removeClass("skindefault"); } if ($("#btnEthnicL").hasClass("skindefault")) { $("#btnEthnicL").removeClass("skindefault"); } if ($("#btnEthnicW").hasClass("skindefault")) { $("#btnEthnicW").removeClass("skindefault"); } } if (currentEthncitysetting == 'B') { $("#btnEthnicB").addClass("skindefault"); if ($("#btnEthnicL").hasClass("skindefault")) { $("#btnEthnicL").removeClass("skindefault"); } if ($("#btnEthnicW").hasClass("skindefault")) { $("#btnEthnicW").removeClass("skindefault"); } if ($("#btnEthnicA").hasClass("skindefault")) { $("#btnEthnicA").removeClass("skindefault"); } } if (currentEthncitysetting == 'A') { $("#btnEthnicL").addClass("skindefault"); if ($("#btnEthnicB").hasClass("skindefault")) { $("#btnEthnicB").removeClass("skindefault"); } if ($("#btnEthnicW").hasClass("skindefault")) { $("#btnEthnicW").removeClass("skindefault"); } if ($("#btnEthnicA").hasClass("skindefault")) { $("#btnEthnicA").removeClass("skindefault"); } } if (currentEthncitysetting == 'W') { $("#btnEthnicW").addClass("skindefault"); if ($("#btnEthnicB").hasClass("skindefault")) { $("#btnEthnicB").removeClass("skindefault"); } if ($("#btnEthnicL").hasClass("skindefault")) { $("#btnEthnicL").removeClass("skindefault"); } if ($("#btnEthnicA").hasClass("skindefault")) { $("#btnEthnicA").removeClass("skindefault"); } } } $rootScope.ChangeEthnicity = function (formsetting, skintone) { formsetting.ethnicity = skintone; $rootScope.setEthncitySettings(formsetting.ethnicity); } $rootScope.ChangeModesty = function (formsetting, modestyValue) { formsetting.modesty = modestyValue; $rootScope.setModestySettings(formsetting.modesty); } $rootScope.CloseSetting = function () { $rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity); $rootScope.setModestySettings($rootScope.globalSetting.modesty); $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); } $rootScope.UpdateAndCloseSetting = function (setting) { $rootScope.UpdateSetting(setting); $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); }; $rootScope.CloseSettingPopup = function () { $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); } $rootScope.UpdateSetting = function (setting) { var isReloadingViewRequired = false; //1. if (typeof (setting.ethnicity) !== "undefined" && setting.ethnicity !== null) { $rootScope.ChangeEthnicity(setting, setting.ethnicity); } if (typeof (setting.modesty) !== "undefined" && setting.modesty !== null) { $rootScope.ChangeModesty(setting, setting.modesty); } //2. if ((setting.ethnicity != null && setting.ethnicity != $rootScope.globalSetting.ethnicity) && (setting.modesty != null && setting.modesty != $rootScope.globalSetting.modesty)) { $rootScope.globalSetting.ethnicity = setting.ethnicity; localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity); $rootScope.globalSetting.modesty = setting.modesty; localStorage.setItem("globalModesty", setting.modesty); isReloadingViewRequired = true; } else if (setting.ethnicity != null && setting.ethnicity != $rootScope.globalSetting.ethnicity) { $rootScope.globalSetting.ethnicity = setting.ethnicity; localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity); $rootScope.globalSetting.modesty = localStorage.getItem("globalModesty"); isReloadingViewRequired = true; } else if (setting.modesty != null && setting.modesty != $rootScope.globalSetting.modesty) { $rootScope.globalSetting.modesty = setting.modesty; localStorage.setItem("globalModesty", $rootScope.globalSetting.modesty); $rootScope.globalSetting.ethnicity = localStorage.getItem("globalEthnicity"); if ($('.modestyImg') != null) { if (($rootScope.globalSetting.modesty == 'Y')) { $('.modestyImg').css('visibility', 'visible'); } else { $('.modestyImg').css('visibility', 'hidden'); } } $rootScope.changeNavigatorModesty(); } var len = $rootScope.openModules.length; if (len > 0) { if (isReloadingViewRequired == true) { $rootScope.reloadChildController(); } } else { $('#modal-settings').css("display", "none"); $("#modelsettingsbackground").css("display", "none"); } }; $rootScope.reloadChildController = function () { var len = $rootScope.openModules.length; var currentOpenModuleId = $rootScope.openModules[len - 1].ModuleId; //checking is DA module is opend. if (currentOpenModuleId == 1) { //Check that what current bodyview is open if ($rootScope.openViews.length > 0) { var openViewLen = $rootScope.openViews.length; var currentOpenViewId = localStorage.getItem("currentBodyViewId");//$rootScope.openViews[openViewLen - 1].BodyViewId; $rootScope.isSettingEventAlredayDispachted = true; $rootScope.$broadcast('reloadDABodyViewEvent', { reloadDABodyViewId: currentOpenViewId }, true); } else { $rootScope.$broadcast('reloadDAControllerEvent', true); } } }; $rootScope.changeNavigatorModesty = function () { var currentOpenViewId = localStorage.getItem("currentBodyViewId");//$rootScope.openViews[openViewLen - 1].BodyViewId; $rootScope.$broadcast('changeNavigatorModestyEvent', { bodyViewId: currentOpenViewId }, true); }; $rootScope.ShowExportImageWindow = function () { $(".export-image").css("display", "block"); }; $rootScope.CloseExportImageWindow = function () { console.log('close') $(".export-image").css("display", "none"); }; $rootScope.ShowPrintWindow = function () { // Print Active Viewer html2canvas($("#canvasDiv"), { onrendered: function (canvas) { var dataURL = canvas.toDataURL("image/jpeg"); var imageToPrint = new Image(); imageToPrint.src = dataURL; $('#snipImage').attr('src', dataURL); $('#spnModule').text($rootScope.currentActiveModuleTitle); $('#spnBodyViewTitle').text(localStorage.getItem('currentViewTitle')); PrintDivContentByID('printBox'); // Open Print Window } }); }; $rootScope.ShowPrintPreviewWindow = function (event) { // Print Preview $rootScope.CloseAnnotationTool(); $("#annotationButton").parent().addClass("disableMenuannotation"); $("#annotationToolBarOptions").addClass("disableMenuoption"); $('#dvPrintPreview').css('display', 'block'); html2canvas($("#canvasDiv"), { onrendered: function (canvas) { var dataURL = canvas.toDataURL("image/jpeg"); var imageToPrint = new Image(); imageToPrint.src = dataURL; OpenJSPanel(); // open jsPanel here if ($('#jsPanel-1').length > 0) { $('.jsPanel-btn-min').attr('style', 'display: none'); $('.jsPanel-btn-max').attr('style', 'display: none'); $('.jsPanel-btn-norm').attr('style', 'display: none'); } console.log('jsPanel loaded exist= ' + document.getElementById('jsPanel-1')); // document.getElementsByClassName('ppImagePanel')); var curModule = $rootScope.currentActiveModuleTitle; var curPosture = localStorage.getItem('currentViewTitle'); if (document.getElementById('jsPanel-1')) { //document.getElementsByClassName('ppImagePanel')) { setTimeout(function () { document.getElementById('imgPortrait').setAttribute('src', dataURL); document.getElementById('imgLandscape').setAttribute('src', dataURL); document.getElementById('spnModulePor').innerHTML = curModule; document.getElementById('spnBodyViewTitlePor').innerHTML = curPosture; document.getElementById('spnModuleLan').innerHTML = curModule; document.getElementById('spnBodyViewTitleLan').innerHTML = curPosture; if ($('#printcontainer').length > 0) { $("#printcontainer").css('width', $(window).outerWidth()); $("#printcontainer").css('height', $(window).outerHeight()); } }, 320); } $('#fileMenuAnchor').addClass('disableMenuannotation'); if ($('#daImagePanel').length > 0) { console.log('close') //$('#daImagePanel').css('display', 'none'); $('#daImagePanel').remove(); } } }); }; function OpenJSPanel() { $.jsPanel({ id: 'jsPanel-1', selector: '#dvPrintPreview', theme: 'success', currentController: 'HomeController', parentSlug: 'da-view-list', //After closing panel, control moves to here ajax: { url: 'app/views/home/printPreview.html' }, title: localStorage.getItem("currentViewTitle"), position: { top: 70, left: 1, }, size: { width: $(window).outerWidth(), height: $(window).outerHeight() + 60}, }); } // $().on('', '', callback); $(document).on('change', 'input[name=inlineRadioOptions]', function () { if ($(this).attr("value") == "Portrait") { $(".print-box").not(".portrait-box").hide(); $(".portrait-box").show(); } if ($(this).attr("value") == "Landscape") { $(".print-box").not(".landscape-box").hide(); $(".landscape-box").show(); } }); $(document).on('change', '#printPSOptions', function () { var option = $('#printPSOptions').find(":selected").text(); switch (option) { case (option = "10%"): ResizeImage(0.1); break; case (option = "25%"): ResizeImage(0.25); break; case (option = "50%"): ResizeImage(0.5); break; case (option = "75%"): ResizeImage(.75); break; case (option = "65%"): ResizeImage(0.65); break; case (option = "100%"): ResizeImage(1); break; case (option = "150%"): ResizeImage(1.5); break; case (option = "200%"): ResizeImage(2); break; case (option = "500%"): ResizeImage(5); break; case (option = "Auto"): ResizeImage(0); break; default: ResizeImage(0); } }); $(document).on('click', '#btnPrint', function () { PrintDivContentByID('printBoxPor'); }); function PrintDivContentByID(id) { if (id == 'printBoxPor') { $("#printPSOptions").val("100%"); ResizeImage(1); } var contents = document.getElementById(id).innerHTML; var frame1 = $('