'use strict';
AIA.controller("HomeController", ["$rootScope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants",
function ($rootScope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, 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
};
// on refersh this variable will also get null that is why we are only checking this variable on initialize that if it is null that means page gets refershed.
$rootScope.refreshcheck = 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.errorMessage = ''; // Commented initialization to retain message when coming to login after password reset success screen
$rootScope.disableFileMenu = "disableFileMenu";
$rootScope.userInfo = {
username: null,
password: null,
emailId: null,
newPassword: null,
confirmPassword: null,
userMessage: null,
unblockUser: false,
isMailForForgotPassword:false
};
$rootScope.userLicenseInfo = {
userLicenseId: 0,
licenseeAccountNumber: null
};
$rootScope.userData;
$rootScope.userModules;
$rootScope.passwordMismatchMessage;
$rootScope.isVisibleLogin;
$rootScope.haveRoleAdmin;
$rootScope.checked = false;
var isfilloptionChecked = "";
var isOutlineOptionChecked = "";
$rootScope.forgotPwdModalShow = function () {
document.getElementById("forgetPwdForm").reset()
$("#forgotPwdModal").modal("show");
$(".modal-backdrop").css("opacity", ".5");
$("body.modal-open").css("padding-right", "0px");
}
$rootScope.forgotUserModalShow = function () {
document.getElementById("forgetUSerIdForm").reset();
$("#forgotUserModal").modal("show");
$(".modal-backdrop").css("opacity", ".5");
$("body.modal-open").css("padding-right", "0px");
}
$rootScope.initializeAIA = function () {
$rootScope.isLoading = false;
var url = $location.url();
if (url.indexOf('?unb:') != -1) {
$rootScope.isVisibleLogin = true;
$rootScope.UnblockUser();
}
else if (url.indexOf('?em:') != -1) {
$rootScope.isVisibleLogin = false;
$rootScope.isVisibleResetPass = true;
}
else {
$rootScope.isVisibleLogin = true;
$rootScope.isVisibleResetPass = false;
getUserDetails();
}
}
$rootScope.AuthenticateUser = function (userInfo) {
$rootScope.errorMessage = "";
if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) {
// alert(LoginMessageConstants.USER_CREDENTIALS_MISSING);
$rootScope.errorMessage = LoginMessageConstants.USER_CREDENTIALS_MISSING;
$("#messageModal").modal('show');
}
else {
AuthenticationService.authenticateUser(userInfo)
.then(
function (result) {
if (result == LoginConstants.USER_NOT_FOUND) {
$rootScope.isVisibleLogin = true;
// alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
$rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
$("#messageModal").modal('show');
}
else {
if (typeof result.LoginId != undefined || result.LoginId != "" || result.LoginId != null) {
if ($("#messageModal").length > 0) {
$("#messageModal").modal('hide');
}
if (result.LoginFailureCauseId!=undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_PASSWORD_NOT_MATCH) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.INVALID_PASSWORD;
$("#messageModal").modal('show');
}
else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_USER_ID_BLOCKED_24_HRS)
{
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.USER_BLOCKED;
$("#messageModal").modal('show');
}
else if ((result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_USER_NOT_ACTIVE) && (result.LicenseInfo != null) && (result.LicenseInfo != undefined) && (result.LicenseInfo.IsActive) && result.IsSubscriptionExpired)
{
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
$rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else if ((result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_USER_NOT_ACTIVE) && (result.LicenseInfo != null) && (result.LicenseInfo != undefined) && (!result.LicenseInfo.IsActive) && result.IsSubscriptionExpired) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
$rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else if ((result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_USER_NOT_ACTIVE) && (result.LicenseInfo != null) && (result.LicenseInfo != undefined) && (!result.LicenseInfo.IsActive) && result.IsSubscriptionExpired) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
$rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else if ((result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_USER_NOT_ACTIVE) && (result.LicenseInfo != null) && (result.LicenseInfo != undefined) && (!result.LicenseInfo.IsActive) && (!result.IsSubscriptionExpired)) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.LICENSE_INACTIVE_MESSAGE + ' ' + LoginMessageConstants.USER_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_USER_NOT_ACTIVE) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.USER_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else if ( (result.LicenseInfo!= null) && (result.LicenseInfo!= undefined) && (!result.LicenseInfo.IsActive) && (result.IsSubscriptionExpired)) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
$rootScope.errorMessage = $rootScope.errorMessage + ' ' + LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else if ((result.LicenseInfo!= null) && (result.LicenseInfo!= undefined) && (result.LicenseInfo.IsActive) && (result.IsSubscriptionExpired)) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.SUBSCRIPTION_EXPIRATION_MESSAGE + result.SubscriptionExpirationDate + '.';
$("#messageModal").modal('show');
}
else if ((result.LicenseInfo!= null) && (result.LicenseInfo!= undefined) && (!result.LicenseInfo.IsActive) && (!result.IsSubscriptionExpired)) {
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else {
if (result.UserType == UserTypeConstants.SUPER_ADMIN && result.IsActive) { //(!result.IsSubscriptionExpired) &&
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
$rootScope.isVisibleLogin = false;
$rootScope.haveRoleAdmin = true;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
ShowAssignedModulesPopup(result.Modules);
$location.path('/');
}
else {
if (result.LicenseInfo != null && result.LicenseInfo.IsTermAccepted) {
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
$rootScope.isVisibleLogin = false;
$rootScope.haveRoleAdmin = false;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
ShowAssignedModulesPopup(result.Modules);
$location.path('/');
}
else {
if ($('#dvTerms').length > 0) {
$('#dvTerms').html(result.TermsAndConditionsText);
}
$rootScope.isVisibleLogin = true;
$('#dvTermCondition').fadeIn();
$rootScope.userData = result;
$rootScope.haveRoleAdmin = false;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
$location.path('/');
}
}
}
}
}
}),
function (error) {
console.log(' Error in authentication = ' + error.statusText);
// alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
}
}
function ShowAssignedModulesPopup(userModules) {
$('#dvUserModulesInfo').modal('hide');
$('#dvPending').modal('hide');
var allModules = Modules;
var arrPendingModules = [];
for (var count = 0; count < userModules.length; count++) {
for (var module = 0; module < allModules.length; module++) {
if (userModules[count].id == allModules[module].Id) {
$('#dvUserModules').append('
');
break;
}
if (userModules[count].id == 7) {
arrPendingModules.push(userModules[count]);
break;
}
if (userModules[count].id == 8) {
arrPendingModules.push(userModules[count]);
break;
}
if (userModules[count].id == 10) {
arrPendingModules.push(userModules[count]);
break;
}
}
}
if (userModules.length > 0) {
$('#dvUserModulesInfo').modal('show');
}
if (arrPendingModules.length > 0) {
$('#dvPending').modal('show');
for (var module = 0; module < arrPendingModules.length; module++) {
$('#dvPendingModules').append('');
}
$('#dvPendingModules').show();
}
}
$rootScope.UpdateLicenseTermStatus = function () {
$('#dvTermCondition').fadeOut();
var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
if (currentUserDetails) {
var userInfo = JSON.parse(currentUserDetails);
}
if (userInfo.LicenseInfo.AccountNumber != null && userInfo.LicenseInfo.Id != 0) {
$rootScope.userLicenseInfo.userLicenseId = userInfo.LicenseInfo.Id;
$rootScope.userLicenseInfo.licenseeAccountNumber = userInfo.LicenseInfo.AccountNumber;
AuthenticationService.UpdateLicenseTerm($rootScope.userLicenseInfo)
.then(function (result) {
if (result.Modules !=="" && result.Modules !== null) { // LoginMessageConstants.LICENSE_TERM_CONDITION_UPDATE_SUCCESS) {
console.log(' Term and Condition acceptance status updated successfully.');
if (currentUserDetails) {
var userInfo = JSON.parse(currentUserDetails);
userInfo.Modules = result.Modules;
if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) {
$rootScope.isVisibleLogin = false;
$rootScope.userData = userInfo;
$rootScope.userModules = userInfo.Modules;
ShowAssignedModulesPopup(userInfo.Modules);;
}
}
}
else if (result = LoginConstants.LICENSE_TERM_CONDITION_UPDATE_FAILED) {
console.log(result);
$rootScope.isVisibleLogin = true;
$('#dvTermCondition').fadeIn();
$rootScope.errorMessage = LoginConstants.LICENSE_TERM_CONDITION_UPDATE_FAILED;
$("#messageModal").modal('show');
$("#messageModal").css("z-index", 111112);
localStorage.removeItem("loggedInUserDetails");
}
},
function (error) {
console.log(' Error in Term and Condition acceptance status update = ' + error);//.statusText
$rootScope.isVisibleLogin = true;
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
$('#dvTermCondition').fadeIn();
});
}
};
$rootScope.LogoutUser = function () {
localStorage.removeItem('loggedInUserDetails');
localStorage.clear();
document.location = '/';
$rootScope.isVisibleLogin = true;
}
function getUserDetails() { //Retain logged in user details
var currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
if (currentUserDetails) {
try {
var userInfo = JSON.parse(currentUserDetails);
if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) {
if (userInfo.UserType == UserTypeConstants.SUPER_ADMIN && userInfo.IsActive) { //(!result.IsSubscriptionExpired) &&
$rootScope.userData = userInfo;
$rootScope.userModules = userInfo.Modules;
$rootScope.isVisibleLogin = false;
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
}
else
{
if (userInfo.LicenseInfo.IsTermAccepted) {
$rootScope.userData = userInfo;
$rootScope.userModules = userInfo.Modules;
$rootScope.isVisibleLogin = false;
//$rootScope.haveRoleAdmin = true;
if ($rootScope.refreshcheck == null) {
$location.path('/');
}
}
else {
if ($('#dvTerms').length > 0) {
$('#dvTerms').html(userInfo.TermsAndConditionsText);
}
$rootScope.isVisibleLogin = true;
$('#dvTermCondition').fadeIn();
$rootScope.userData = userInfo;
$rootScope.userModules = userInfo.Modules;
//$rootScope.haveRoleAdmin = true;
$location.path('/');
}
}
}
}
catch (e) {
localStorage.removeItem('loggedInUserDetails');
}
}
}
$rootScope.SendMailToUser = function (userInfo, isMailForForgotPassword) {
//
if ((userInfo.emailId != null) && (userInfo.emailId != '')) {
if (validateEmail(userInfo.emailId)) {
if (isMailForForgotPassword) {
var selectedOption = $("input[name='inlineRadioOptions']:checked").val();
if (selectedOption == LoginMessageConstants.UNBLOCK_SELECTED) {
userInfo.unblockUser = true;
userInfo.isMailForForgotPassword = true;
}
else if (selectedOption == LoginMessageConstants.FORGOT_PASSWORD_SELECTED) {
userInfo.unblockUser = false;
userInfo.isMailForForgotPassword = true;
}
}
else
userInfo.isMailForForgotPassword = false;
AuthenticationService.SendMailToUser(userInfo)
.then(function (result) {
if (result == LoginConstants.USER_NOT_FOUND) {
removeEmailPopUp();
// alert(LoginMessageConstants.INCORRECT_EMAIL_ID);
$rootScope.errorMessage = LoginMessageConstants.INCORRECT_EMAIL_ID;
$("#messageModal").modal('show');
}
else if (result == LoginConstants.MAIL_NOT_SENT) {
removeEmailPopUp();
// alert(LoginMessageConstants.MAIL_NOT_SENT);
$rootScope.errorMessage = LoginMessageConstants.MAIL_NOT_SENT;
$("#messageModal").modal('show');
}
else {
if (result == LoginMessageConstants.MAIL_SENT) {
var message;
removeEmailPopUp();
if (isMailForForgotPassword) {
if (userInfo.unblockUser)
message = LoginMessageConstants.USER_UNBLOCK_LINK_IN_EMAIL;
else
message = LoginMessageConstants.RESET_PASSWORD;
}
else
message = LoginMessageConstants.USERID_SENT_IN_EMAIL
//alert(message);
$rootScope.errorMessage = message;
$("#messageModal").modal('show');
}
}
},
function (error) {
console.log(' Error in authentication = ' + error.statusText);
removeEmailPopUp();
// alert(LoginConstants.ERROR_IN_FECTHING_DETAILS);
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
});
}
else {
// alert(LoginMessageConstants.INCORRECT_EMAIL_ID);
removeEmailPopUp();
$rootScope.errorMessage = LoginMessageConstants.INCORRECT_EMAIL_ID;
$("#messageModal").modal('show');
}
}
else {
//alert(LoginMessageConstants.BLANK_EMAIL_ID);
removeEmailPopUp();
$rootScope.errorMessage = LoginMessageConstants.BLANK_EMAIL_ID;
$("#messageModal").modal('show');
}
};
function removeEmailPopUp()
{
if ($('#forgotUserModal').length > 0) {
$('#forgotUserModal').fadeOut();
$('#forgotUserModal').modal('hide');
}
if ($('#forgotPwdModal').length > 0) {
$('#forgotPwdModal').fadeOut();
$('#forgotPwdModal').modal('hide');
}
}
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 != null) {
if (userInfo.newPassword === userInfo.confirmPassword) {
$rootScope.passwordMismatchMessage = null;
AuthenticationService.ResetUserPassword(userInfo)
.then(
function (result) {
if (result == LoginConstants.USER_NOT_FOUND) {
// alert(LoginMessageConstants.USER_OR_PASSWORD_INCORRECT);
$rootScope.errorMessage = LoginMessageConstants.USER_NOT_FOUND;
$("#messageModal").modal('show');
}
else if (result == LoginConstants.EXCEPTION_OCCURED) {
// alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS);
$rootScope.errorMessage = LoginConstants.ERROR_IN_FECTHING_DETAILS;
$("#messageModal").modal('show');
}
else if (result == LoginConstants.SQL_CONNECTION_ERROR) {
$rootScope.errorMessage = LoginConstants.SQL_CONNECTION_ERROR_MESSAGE;
$("#messageModal").modal('show');
}
else {
//if ((result.IsAcknowledged == true) && (result.IsModifiedCountAvailable == true)) {
if (result == LoginMessageConstants.PASSWORD_UPDATE_SUCCESS) {
// alert(LoginMessageConstants.PASSWORD_RESET_MESSAGE);
$rootScope.errorMessage = LoginMessageConstants.PASSWORD_RESET_MESSAGE;
$("#messageModal").modal('show');
$rootScope.isVisibleLogin = true;
$rootScope.isVisibleResetPass = false;
$location.url("/");
}
else {
$rootScope.errorMessage = LoginMessageConstants.PASSWORD_RESET_FAILURE;
$("#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.errorMessage = error;
$("#messageModal").modal('show');
});
}
else {
$rootScope.errorMessage = LoginMessageConstants.NEW_AND_OLD_PASSWORD_DONOT_MATCH;
$("#messageModal").modal('show');
}
}
else {
$rootScope.errorMessage = LoginMessageConstants.NEW_PASSWORD_FIELD_IS_EMPTY;
$("#messageModal").modal('show');
}
}
$rootScope.UnblockUser = function () {
var userEmailId = '';
var url = $location.url();
var split = url.split('?unb:');
userEmailId = split[1];
AuthenticationService.UnblockUser(userEmailId)
.then(
function (result) {
if (result == LoginMessageConstants.USER_UNBLOCK_SUCCESS) {
$rootScope.errorMessage = LoginMessageConstants.USER_UNBLOCK_SUCCESS_MESSAGE;
$("#messageModal").modal('show');
$rootScope.isVisibleLogin = true;
$location.url("/");
}
else {
$rootScope.errorMessage = LoginMessageConstants.UNABLE_TO_UNBLOCK;
$("#messageModal").modal('show');
$rootScope.isVisibleLogin = true;
$location.url("/");
}
},
function (error) {
console.log(' Error in UnblockUser = ' + error.statusText);
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
);
}
$rootScope.lexiconLanguageArray = [];
$rootScope.lexiconLanguageArray.push({ id: "1", language: "English" });
$(document).ready(function () {
$rootScope.isLexiconTabClicked = true;
$rootScope.lexiconData = function () {
if ($rootScope.isLexiconTabClicked == true) {
$rootScope.isLexiconTabClicked = false;
$.ajax({
url: '~/../content/data/json/da/uc_dat_default.json',
dataType: "json",
success: function (result) {
$(result.root.uc.al.lx).each(function (key, value) {
$('#lexiconLangDropdown').append('');
});
}
});
}
$('#lexiconLangDropdown').change(function () {
$rootScope.isLexiconLanguageClicked = true;
$('#laxiconLangAdd').removeAttr('disabled');
$('#laxicanlanguageChagne').removeAttr('disabled');
$rootScope.selectedId = $("#lexiconLangDropdown option:selected").attr('val');
$rootScope.selectedText = $("#lexiconLangDropdown option:selected").text();
});
$('#laxiconLangAdd').click(function () {
if ($rootScope.isLexiconLanguageClicked == true) {
$rootScope.isLexiconLanguageClicked = false;
$("#lexiconLangDropdown :selected").remove();
$('#secondLax').append('');
$rootScope.lexiconLanguageArray.push({ id: $rootScope.selectedId, language: $rootScope.selectedText });
}
});
$('#secondLax').change(function () {
$rootScope.isActiveLexiconLanguageClicked = true;
$rootScope.secondlaxdid = $("#secondLax option:selected").attr('val');
$rootScope.secondlaxtext = $("#secondLax option:selected").text();
});
$("#laxiconLangRemove").click(function () {
if ($rootScope.isActiveLexiconLanguageClicked == true) {
$rootScope.isActiveLexiconLanguageClicked = false;
$("#secondLax :selected").remove();
$('#lexiconLangDropdown').append('');
// $rootScope.lexiconLanguageArray.splice($rootScope.secondlaxtext, 1);
$rootScope.lexiconLanguageArray = [];
$("#secondLax > option").each(function () {
$rootScope.lexiconLanguageArray.push({ id: $(this).attr("val"), language: this.value });
});
$rootScope.lexiconLanguageArray.unshift({ id: $("#primarylaxican").attr("name"), language: $("#primarylaxican").val() });
}
});
$("#laxicanlanguageChagne").click(function () {
if ($rootScope.isLexiconLanguageClicked == true) {
$rootScope.isLexiconLanguageClicked = false;
var primarylaxiid = $("#lexiconLangDropdown option:selected").attr('val');
var primarylaxicantext = $("#lexiconLangDropdown option:selected").text();
$("#lexiconLangDropdown :selected").remove();
$('#lexiconLangDropdown').append('');
$('#primarylaxican').val(primarylaxicantext);
$('#primarylaxican').attr("name", primarylaxiid);
$rootScope.lexiconLanguageArray[0].id = primarylaxiid;
$rootScope.lexiconLanguageArray[0].language = primarylaxicantext;
}
});
}
if ($.browser.msie) {
$("#resetBtn").css("display", "inline-block");
// $rootScope.refreshCanvas();
}
$(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");
$("#optionsListManagerTab").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");
$("#optionsListManagerTab").addClass("disableSubMenu");
$rootScope.disableFileMenu = " ";
}
else if ($location.url() == "/module-item-view") {
$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");
$("#optionsListManagerTab").addClass("disableSubMenu");
$rootScope.disableFileMenu = "disableFileMenu";
}
else {
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$("#optionsListManagerTab").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.getModuleScrollPosition = function () {
$rootScope.refreshcheck = "check";
$('.mCSB_container ul li').click(function () {
$rootScope.scrollTopPosition = $(this).position().top;
});
setTimeout(function () {
$(".sidebar").mCustomScrollbar("scrollTo", $rootScope.scrollTopPosition + "px");
}, 300);
}
$rootScope.openParent = function (slug) {
if ($('#jsPanel-1').length > 0) {
}
else {
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();
if ($('#3DImagePanel').length > 0)
$('#3DImagePanel').remove();
if ($('#ciImagePanel').length > 0)
$('#ciImagePanel').remove();
if ($('#caVideoPanel').length > 0)
$('#caVideoPanel').remove();
if ($('#ImagePanel').length > 0)
$('#ImagePanel').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" || $rootScope.MenuModuleName == "AA") {
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();
}
if ($location.url() == "/module-item-view") {
var canvasZIndex = $("#canvas").css("z-index");
var canvasPaintZIndex = $("#canvasPaint").css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$("#aaDetailViewCanvas").css("z-index", canvasPaintZIndex);
}
else
{
canvasZIndex = parseInt(canvasZIndex) + 1;
$("#aaDetailViewCanvas").css("z-index", canvasZIndex);
}
}
}
$rootScope.CloseAnnotationTool = function () {
console.log('close');
$rootScope.isAnnotatiomToolBarPopupActive = false;
$rootScope.isAnnotatiomToolBarPopupClosed = true;
$("#OnIdentify").removeClass("annotationtoolbartab");
$("#DrawMode").removeClass("annotationtoolbartab");
$('.btnCursor').removeClass('activebtncolor');
$("#annotationButton").removeClass("active");
$("#annotationButton").blur();
$("#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 = '';
if ($location.url() == "/module-item-view") {
var canvasZIndex = $("#canvas").css("z-index");
var canvasPaintZIndex = $("#canvasPaint").css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$("#aaDetailViewCanvas").css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$("#aaDetailViewCanvas").css("z-index", canvasZIndex);
}
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
for (var j = 0; j <= $rootScope.aaPinDataArray.length - 1; j++) {
if (($rootScope.jcanvasObjectArray[i].x <= parseInt($rootScope.aaPinDataArray[j]._HeadX) && $rootScope.jcanvasObjectArray[i].y <= parseInt($rootScope.aaPinDataArray[j]._HeadY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt($rootScope.aaPinDataArray[j]._HeadX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt($rootScope.aaPinDataArray[j]._HeadY)) || ($rootScope.jcanvasObjectArray[i].x <= parseInt($rootScope.aaPinDataArray[j]._PinX) && $rootScope.jcanvasObjectArray[i].y <= parseInt($rootScope.aaPinDataArray[j]._PinY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt($rootScope.aaPinDataArray[j]._PinX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt($rootScope.aaPinDataArray[j]._PinY))) {
var pinName = 'Pin_' + $rootScope.aaPinDataArray[j]._PinId;
var pinArcName = 'PinArc_' + $rootScope.aaPinDataArray[j]._PinId;
$('#aaDetailViewCanvas').setLayer(pinName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
$('#aaDetailViewCanvas').setLayer(pinArcName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
}
}
}
}
}
$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();
}
if ($location.url() == "/module-item-view") {
var canvasZIndex = $("#canvas").css("z-index");
var canvasPaintZIndex = $("#canvasPaint").css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$("#aaDetailViewCanvas").css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$("#aaDetailViewCanvas").css("z-index", canvasZIndex);
}
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
for (var j = 0; j <= $rootScope.aaPinDataArray.length - 1; j++) {
if (($rootScope.jcanvasObjectArray[i].x <= parseInt($rootScope.aaPinDataArray[j]._HeadX) && $rootScope.jcanvasObjectArray[i].y <= parseInt($rootScope.aaPinDataArray[j]._HeadY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt($rootScope.aaPinDataArray[j]._HeadX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt($rootScope.aaPinDataArray[j]._HeadY)) || ($rootScope.jcanvasObjectArray[i].x <= parseInt($rootScope.aaPinDataArray[j]._PinX) && $rootScope.jcanvasObjectArray[i].y <= parseInt($rootScope.aaPinDataArray[j]._PinY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt($rootScope.aaPinDataArray[j]._PinX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt($rootScope.aaPinDataArray[j]._PinY))) {
var pinName = 'Pin_' + $rootScope.aaPinDataArray[j]._PinId;
var pinArcName = 'PinArc_' + $rootScope.aaPinDataArray[j]._PinId;
$('#aaDetailViewCanvas').setLayer(pinName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
$('#aaDetailViewCanvas').setLayer(pinArcName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
}
}
}
}
}
$rootScope.switchToTransparencycanvas = function () {
if ($rootScope.isTBoxModestyVisible == 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);
if ($rootScope.currentBodyViewId == "11") {
$(".ui-wrapper").css("z-index", MaxZindexVal + 1);
$('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal);
}
else {
$('#' + 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);
if ($rootScope.currentBodyViewId == "11") {
$(".ui-wrapper").css("z-index", MaxZindexVal);
}
else
{
$('#' + ctx.getAttribute("id")).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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
for (var j = 0; j <= $rootScope.aaPinDataArray.length - 1; j++) {
if (($rootScope.jcanvasObjectArray[i].x <= parseInt($rootScope.aaPinDataArray[j]._HeadX) && $rootScope.jcanvasObjectArray[i].y <= parseInt($rootScope.aaPinDataArray[j]._HeadY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt($rootScope.aaPinDataArray[j]._HeadX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt($rootScope.aaPinDataArray[j]._HeadY)) || ($rootScope.jcanvasObjectArray[i].x <= parseInt($rootScope.aaPinDataArray[j]._PinX) && $rootScope.jcanvasObjectArray[i].y <= parseInt($rootScope.aaPinDataArray[j]._PinY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt($rootScope.aaPinDataArray[j]._PinX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt($rootScope.aaPinDataArray[j]._PinY))) {
var pinName = 'Pin_' + $rootScope.aaPinDataArray[j]._PinId;
var pinArcName = 'PinArc_' + $rootScope.aaPinDataArray[j]._PinId;
$('#aaDetailViewCanvas').setLayer(pinName, {
visible: true // set to true instead to show the layer again
}).drawLayers();
$('#aaDetailViewCanvas').setLayer(pinArcName, {
visible: true // set to true instead to show the layer again
}).drawLayers();
}
}
}
}
}
// 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");
}
$rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length;
$rootScope.lexiconPrimaryLanguage = $("#primarylaxican").val();
$rootScope.primaryLangID = $('#primarylaxican').attr("name");
}
//----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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$rootScope.switchToAnnotationCanvas = function () {
var aaViewCanvasZIndex = $("#aaDetailViewCanvas").css("z-index");
var canvasPaintZIndex = $("#canvasPaint").css("z-index");
if (parseInt(aaViewCanvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$("#canvas").css("z-index", canvasPaintZIndex);
}
else {
aaViewCanvasZIndex = parseInt(aaViewCanvasZIndex) + 1;
$("#canvas").css("z-index", aaViewCanvasZIndex);
}
}
$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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$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') == "transparent") || ($("#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.isTBoxModestyVisible == 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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$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;
if ($location.url() == "/module-item-view") {
$rootScope.switchToAnnotationCanvas();
}
}
$rootScope.switchCanvas = function () {
if ($rootScope.isTBoxModestyVisible == 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")) {
if ($rootScope.currentBodyViewId == "11") { $("#canvasPaint").css("z-index", MaxZindexVal + 1); }
else{ $("#canvasPaint").css("z-index", MaxZindexVal);}
}
else {
if ($rootScope.currentBodyViewId == "11") {
$("#canvas").css("z-index", MaxZindexVal + 1);
}
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" });
}
if ((isfilloptionChecked == false) && (isOutlineOptionChecked == false)) {
$(".setEnableDisableForEditShapeStyle").css({ "opacity": "1" });
$("#borderWidthCanvasElement").css({ "pointer-events": "auto" });
$("#outlineColor").css({ "pointer-events": "auto" });
$(".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" });
document.getElementById("editStyleForm").reset();
}
var previewBgColor = $("#shapeStyleDiv").css('background-color');
var previewBorderColor = $('#previewBorder').css('border-top-color');
var previewBorderWidth = $('#previewBorder').css('border-top-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.jcanvasObjectArray = [];
$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,
add: function (layer) {
if ($location.path() == "/module-item-view") {
$rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
change: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
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) {
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',
add: function (layer) {
if ($location.path() == "/module-item-view") {
$rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
change: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
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 });
if ($location.path() == "/module-item-view") {
$rootScope.initialTextAreaName = layer.name;
$rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
change: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = 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) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == $rootScope.initialTextAreaName) {
$rootScope.jcanvasObjectArray.splice(i, 1);
$rootScope.initialTextAreaName = '';
}
}
}
// 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];
if ($location.path() == "/module-item-view") {
$rootScope.initialTextAreaName = layer.name;
$rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
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: 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.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: 5, height: 5,
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;
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
}
}
}
}).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 {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == $rootScope.initialTextAreaName) {
$rootScope.jcanvasObjectArray.splice(i, 1);
$rootScope.initialTextAreaName = '';
}
}
}
// 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];
if ($location.path() == "/module-item-view") {
$rootScope.jcanvasObjectArray.push({ "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
},
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: 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.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: 10, height: 10,
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;
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].name == layer.name) {
$rootScope.jcanvasObjectArray[i].x = layer.x;
$rootScope.jcanvasObjectArray[i].y = layer.y;
$rootScope.jcanvasObjectArray[i].width = layer.width;
$rootScope.jcanvasObjectArray[i].height = layer.height;
}
}
}
}
}
}
}).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 = "";
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.canvasLayerNameCollection[0].textareaRectangle == $rootScope.jcanvasObjectArray[i].name) {
$rootScope.jcanvasObjectArray.splice(i, 1);
}
// console.log($rootScope.jcanvasObjectArray);
}
}
else {
$("#canvas").removeLayer($rootScope.canvasLayerNameCollection).drawLayers();
if ($location.path() == "/module-item-view") {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.canvasLayerNameCollection == $rootScope.jcanvasObjectArray[i].name) {
$rootScope.jcanvasObjectArray.splice(i, 1);
}
}
}
}
}
});
$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) {
if ($location.path() == "/module-item-view") {
$timeout(function () {
$('#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" });
}, 1000);
}
else {
$('#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;
if ($location.path() == "/module-item-view") {
$rootScope.refreshTermListOnAASystemSelection($rootScope.selectedBodySystemId);
}
else {
if ($location.path() == "/module-item-view") {
$rootScope.refreshTermListOnAASystemSelection($rootScope.selectedBodySystemId);
}
else {
$rootScope.refreshTermListOnSystemSelection($rootScope.selectedBodySystemId);
}
}
}
else {
if ($location.path() == "/module-item-view") {
$rootScope.refreshTermListOnAASystemSelection($rootScope.selectedBodySystemId);
}
else {
$rootScope.refreshTermListOnSystemSelection($rootScope.selectedBodySystemId);
}
}
$timeout(function () {
$('#bodySystems option[selected="selected"]').prop("selected", false);
$('#bodySystems option[value="' + $rootScope.selectedBodySystemName + '"]').prop("selected", true);
$("#termList").find("option").css({ "background-color": "#ffffff", "color": "#000000" });
$('#termList option[value="' + $rootScope.searchSelectedText + '"]').css({ "background-color": "#3399FF", "color": "#ffffff" });
}, 1000);
}
$("#optionsListManagerTab").addClass("active");
var viewNameAftrSplit;
if ($("#viewName").val() !== null) {
viewNameAftrSplit = $("#viewName").val().split(" ");
if (viewNameAftrSplit[0] == "null") {
document.location.href = "/";
}
}
if ($location.url() == "/module-item-view") {
$("#termList").attr("onclick", "if (typeof(this.selectedIndex) != 'undefined') onSearchItemSelection(this.options[this.selectedIndex].id)");
}
else {
$("#termList").attr("onclick", "if (typeof(this.selectedIndex) != 'undefined') onListManagerTermSelection(this.options[this.selectedIndex].id, true)");
}
}
$rootScope.CloseListManager = function () {
$("#btnTranparency").removeAttr('disabled', 'disabled');
$("#optionsListManagerTab").removeClass("active");
$rootScope.isListManagerMenuSelected = false;
console.log('listManager closed');
$rootScope.disableAnnotationtoolOnListManager = false;
if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") {
$("#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');
if ($(".annotationTollbar").css("display") == "block") {
$rootScope.switchCanvasToPaintCanvas();
}
}
}
if ($location.path() == "/module-item-view") {
$rootScope.selectedBodySystemName = $("#AABodySystems").val();
$rootScope.selectedBodySystemId = $('#AABodySystems option[value="' + $rootScope.selectedBodySystemName + '"]').attr("id");
}
$('#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 = $rootScope.getLocalStorageValue("globalEthnicity");
if (typeof (curentEthnicity) !== "undefined" && curentEthnicity !== null) {
$rootScope.globalSetting.ethnicity = curentEthnicity;
}
else {
localStorage.setItem("globalEthnicity", $rootScope.globalSetting.ethnicity);
}
var curentmodesty = $rootScope.getLocalStorageValue("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.isApplyBtnClicked = false;
$rootScope.CloseSetting = function () {
$rootScope.setEthncitySettings($rootScope.globalSetting.ethnicity);
$rootScope.setModestySettings($rootScope.globalSetting.modesty);
if ($rootScope.isApplyBtnClicked == false) {
$rootScope.deSelectLanguageOptions();
}
else {
$rootScope.isApplyBtnClicked = false;
}
$('#modal-settings').css("display", "none");
$("#modelsettingsbackground").css("display", "none");
}
$rootScope.UpdateAndCloseSetting = function (setting) {
$rootScope.UpdateSetting(setting);
if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") {
$rootScope.loadSearchData();
}
$rootScope.isApplyBtnClicked = false;
//$timeout(function () {
$('#modal-settings').css("display", "none");
$("#modelsettingsbackground").css("display", "none");
// $("#setting-spinner").css("display", "none");
if ($rootScope.MenuModuleName == "DA" || $rootScope.MenuModuleName == "AA") {
$("#setting-spinner").css("display", "block");
}
$rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length;
// }, 6000);
};
$rootScope.CloseSettingPopup = function () {
if ($rootScope.isApplyBtnClicked == false) {
$rootScope.deSelectLanguageOptions();
}
else {
$rootScope.isApplyBtnClicked = false;
}
$('#modal-settings').css("display", "none");
$("#modelsettingsbackground").css("display", "none");
}
$rootScope.deSelectLanguageOptions = function () {
var languageDifference = ($rootScope.lexiconLanguageArrayLength) - ($rootScope.lexiconLanguageArray.length);
if (languageDifference > 0) {
for (var i = 0; i <= $rootScope.lexiconRemovedLanguage.length - 1; i++) {
$("#lexiconLangDropdown option").each(function () {
if ($rootScope.lexiconRemovedLanguage[i].language == $(this).val()) {
$(this).remove();
$('#secondLax').append('');
$rootScope.lexiconLanguageArray.push({ "id": $rootScope.lexiconRemovedLanguage[i].id, "language": $rootScope.lexiconRemovedLanguage[i].language });
}
});
if ($rootScope.lexiconRemovedLanguage[i].language == $("#primarylaxican").val()) {
$rootScope.lexiconLanguageArray[0].id = $rootScope.primaryLangID;
$rootScope.lexiconLanguageArray[0].language = $rootScope.lexiconPrimaryLanguage;
$("#primarylaxican").val($rootScope.lexiconPrimaryLanguage);
$('#primarylaxican').attr("name", $rootScope.primaryLangID);
$('#secondLax').append('');
$rootScope.lexiconLanguageArray.push({ "id": $rootScope.lexiconRemovedLanguage[i].id, "language": $rootScope.lexiconRemovedLanguage[i].language });
$("#lexiconLangDropdown option").each(function () {
if($rootScope.lexiconPrimaryLanguage == $(this).val()){
$(this).remove();
}
});
}
//$("#primarylaxican").val($rootScope.lexiconPrimaryLanguage);
//$('#primarylaxican').attr("name", $rootScope.primaryLangID);
}
}
else if (languageDifference < 0) {
languageDifference = Math.abs(languageDifference);
for (var i = 1; i <= languageDifference; i++) {
var lexiconArrayLength = $rootScope.lexiconLanguageArray.length;
$("#secondLax option").each(function () {
if ($rootScope.lexiconLanguageArray[lexiconArrayLength - 1].language == $(this).val()) {
$(this).remove();
}
})
$('#lexiconLangDropdown').append('');
$rootScope.lexiconLanguageArray.pop();
}
$rootScope.lexiconLanguageArray[0].id = $rootScope.primaryLangID;
$rootScope.lexiconLanguageArray[0].language = $rootScope.lexiconPrimaryLanguage;
$("#lexiconLangDropdown option").each(function () {
if ($rootScope.lexiconPrimaryLanguage == $(this).val()) {
$(this).remove();
}
})
$('#lexiconLangDropdown').append('');
$("#primarylaxican").val($rootScope.lexiconPrimaryLanguage);
$('#primarylaxican').attr("name", $rootScope.primaryLangID);
}
else if (languageDifference == 0) {
if ($rootScope.lexiconPrimaryLanguage == $("#primarylaxican").val()) {
// alert("same name");
}
else {
$rootScope.lexiconLanguageArray[0].id = $rootScope.primaryLangID;
$rootScope.lexiconLanguageArray[0].language = $rootScope.lexiconPrimaryLanguage;
$("#lexiconLangDropdown option").each(function () {
if ($rootScope.lexiconPrimaryLanguage == $(this).val()) {
$(this).remove();
}
})
$('#lexiconLangDropdown').append('');
$("#primarylaxican").val($rootScope.lexiconPrimaryLanguage);
$('#primarylaxican').attr("name", $rootScope.primaryLangID);
}
}
}
$rootScope.UpdateSetting = function (setting) {
$rootScope.isApplyBtnClicked = true;
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 = $rootScope.getLocalStorageValue("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 = $rootScope.getLocalStorageValue("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.lexiconRemovedLanguage = [];
$("#secondLax option").each(function () {
$rootScope.lexiconRemovedLanguage.push({ "id": $(this).attr("val"), "language": $(this).val() });
});
};
$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 = $rootScope.getLocalStorageValue("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 = $rootScope.getLocalStorageValue("currentBodyViewId");//$rootScope.openViews[openViewLen - 1].BodyViewId;
$rootScope.$broadcast('changeNavigatorModestyEvent', { bodyViewId: currentOpenViewId }, true);
};
$rootScope.ShowExportImageWindow = function () {
$(".export-image").modal("show").draggable({ handle: ".modal-header" });
$(".modal-backdrop").css("opacity", ".5");
$(".modal-backdrop").css("z-index", "1200001");
};
$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($rootScope.getLocalStorageValue('currentViewTitle'));
PrintDivContentByID('printBox'); // Open Print Window
}
});
};
$rootScope.ShowPrintPreviewWindow = function (event) { // Print Preview
if ($location.url() == "/module-item-view") {
if ($("#hidePinBtn").hasClass("btn-primary")) {
$rootScope.isHidePinBtnActiveInPrintPreview = true;
}
if ($("#selectedPin").hasClass("btn-primary")) {
$rootScope.isShowSelectedPinActiveInPrintPrevMode = true;
}
if ($("#allPinBtn").hasClass("btn-primary")) {
$rootScope.isShowAllPinBtnActiveInPrintPreviewMode = true;
}
}
$(".tools").css("z-index", "1029");
$rootScope.CloseListManager();
$rootScope.CloseAnnotationTool();
$("#annotationButton").parent().addClass("disableMenuannotation");
$("#annotationToolBarOptions").addClass("disableMenuoption");
$("#optionsListManagerTab").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-norm').attr('style', 'display: none');
}
console.log('jsPanel loaded exist= ' + document.getElementById('jsPanel-1')); // document.getElementsByClassName('ppImagePanel'));
var curModule = $rootScope.currentActiveModuleTitle;
var curPosture = $rootScope.getLocalStorageValue('currentViewTitle');
if (document.getElementById('jsPanel-1')) { //document.getElementsByClassName('ppImagePanel')) {
if (dataURL == "" || dataURL == undefined) {
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());
}
if ($location.url() == "/module-item-view") {
$("#aaDetailViewCanvas").css("display", "none");
}
}, 520);
}
else {
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());
}
if ($location.url() == "/module-item-view") {
$("#aaDetailViewCanvas").css("display", "none");
}
}, 320);
}
}
$('#fileMenuAnchor').parent().addClass('disableFileMenu');
if ($('#daImagePanel').length > 0) {
console.log('close')
//$('#daImagePanel').css('display', 'none');
// $('#daImagePanel').remove();
}
}
});
if ($location.url() == "/module-item-view") {
$timeout(function () {
$rootScope.hidePins();
}, 100);
}
};
function OpenJSPanel() {
$("#daImagePanel").css({ "pointer-events": "none", "opacity": ".5" });
$("#ciImagePanel").css({ "pointer-events": "none", "opacity": ".5" });
$.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: $rootScope.getLocalStorageValue("currentViewTitle"),
position: {
top: 70,
left: 1,
},
controls: { buttons: 'closeonly' },
size: { width: $(window).outerWidth(), height: $(window).outerHeight() + 60 },
//size: { width: $(window).outerWidth() - 10, height: $(window).outerHeight() - 110 },
});
}
$rootScope.getLocalStorageValue = function (localStorageParam) {
if ((localStorage.getItem('loggedInUserDetails') == null) && ($rootScope.isVisibleLogin == false)) {
if ($location.url().indexOf('?em') == -1 && $location.url().indexOf('?unb') == -1)
$rootScope.LogoutUser();
}
else {
return localStorage.getItem(localStorageParam);
}
}
// $().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 = $('');
frame1[0].name = "frame1";
frame1.css({ "position": "absolute", "top": "-1000000px" });
$("body").append(frame1);
var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument;
frameDoc.document.open();
//Create a new HTML document.
frameDoc.document.write('');//Print Preview
frameDoc.document.write('');
//Append the external CSS file.
frameDoc.document.write('');
frameDoc.document.write('');
//Append the DIV contents.
frameDoc.document.write(contents);
frameDoc.document.write('');
frameDoc.document.close();
setTimeout(function () {
window.frames["frame1"].focus();
window.frames["frame1"].print();
frame1.remove();
}, 320);
console.log('close')
}
$(document).on('click', '#jsPanel-1 .jsglyph-remove', function () {
$("#daImagePanel").css({ "pointer-events": "auto", "opacity": "1" });
$("#ciImagePanel").css({ "pointer-events": "auto", "opacity": "1" });
$("#annotationButton").parent().removeClass("disableMenuannotation");
$("#annotationToolBarOptions").removeClass("disableMenuoption");
$("#optionsListManagerTab").removeClass("disableMenuoption");
$('#fileMenuAnchor').parent().removeClass('disableFileMenu');
$("#aaDetailViewCanvas").css("display", "block");
if ($('#jsPanel-1').length > 0)
$('#jsPanel-1').remove();
console.log('close');
});
$rootScope.restrictBodySystemList = function () {
var RestrictListDiv = document.getElementById("restrictListDiv");
if (RestrictListDiv.style.display == 'block') {
RestrictListDiv.style.display = 'none';
$(".restrict-carret-icon").css({ "transform": "rotate(0deg)", "-moz-transform": "rotate(0deg)", "-webkit-transform": "rotate(0deg)", "-ms-transform": "rotate(0deg)" });
return;
}
RestrictListDiv.style.display = 'block';
$(".restrict-carret-icon").css({ "transform": "rotate(90deg)", "-moz-transform": "rotate(90deg)", "-webkit-transform": "rotate(90deg)", "-ms-transform": "rotate(90deg)" });
}
$rootScope.OpenAdminForm = function (userInfo) {
$('#adminModal').css({ top: '50px' });
if ($rootScope.userData) {
$('#adminfName').val($rootScope.userData.FirstName);
$('#adminlName').val($rootScope.userData.LastName);
$('#adminEmailId').val($rootScope.userData.EmailId);
}
};
$rootScope.SendAdminAccessRequestMail = function (userInfo) {
if ($rootScope.userData) {
userInfo.firstName = $rootScope.userData.FirstName;
userInfo.lastName = $rootScope.userData.LastName;
userInfo.emailId = $rootScope.userData.EmailId;
}
AdminService.SendAdminAccessRequestMail(userInfo)
.then(function (result) {
if (result == AdminConstants.MAIL_SENT) {
$rootScope.errorMessage = AdminConstants.MAIL_SENT_SUCCESS_MESSAGE;
$("#messageModal").modal('show');
}
$("#adminModal").fadeOut();
$("#adminModal").modal('hide');
$('[name="adminAccessTextArea"]').val('');
},
function (error) {
console.log(' Error in sending mail to admin support = ' + error.statusText);
$rootScope.errorMessage = AdminConstants.ERROR_IN_SENDING_MAIL;
$("#messageModal").modal('show');
});
};
$rootScope.CloseAAModal = function () {
$("#adminModal").fadeOut();
$("#adminModal").modal('hide');
$("adminAccessTextArea").text('');
}
$rootScope.addToolTip = function (toolTipTopPosition, toolTipLeftPosition, toolTipWidth, toolTipText) {
$("#cursor-block").addClass("custom-tooltip-annotation-toolbar");
$(".custom-tooltip-annotation-toolbar").css({ "display": "block", "top": toolTipTopPosition + "px", "width": toolTipWidth + "px", "left": toolTipLeftPosition + "px" });
$("#cursor-block").html(toolTipText);
}
$rootScope.removeToolTipOnMouseOut = function () {
$(".custom-tooltip-annotation-toolbar").css('display', 'none');
$("#cursor-block").removeClass("custom-tooltip-annotation-toolbar");
$("#cursor-block").html();
}
$rootScope.CheckRefresh = function (e) {
//Checking if 'REFRESHED' or 'RELOADED'
if ((e.keyCode === 116) || (e.keyCode == 82 && e.ctrlKey))
$location.path('/'); //Redirecting to landing page
};
$rootScope.resetDrawing = function (e) {
$('#canvas').removeLayers();
};
}]
);