'use strict';
AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$compile", "$timeout", "DataService", "AuthenticationService", "ConfigurationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants","ModuleService","$window","Idle", "Keepalive",
function ($rootScope, $scope, Modules, $log, $location, $compile, $timeout, DataService, AuthenticationService, ConfigurationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants, AIAConstants, ModuleService,$window,Idle, Keepalive) {
$rootScope.MULTI_VIEW_ID = 401;
$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;
var isCommingSoonModel = true;
$rootScope.isCloseSettingClicked = false;
$rootScope.isModestyOn;
$rootScope.isModestyOff;
$rootScope.SetSettingActiveTab;
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").addClass("disableMenuoption");
$rootScope.menuLabExer;
$rootScope.menuLabExer = 0;
$rootScope.TextPropertyArray = [];
$rootScope.modifySavedText = [];
$rootScope.TextRectangleArr = [];
$rootScope.rectDimension = [];
$rootScope.textDimension=[];
$rootScope.isMousedownOnPaintCanvas = false;
//opacity code
$rootScope.shapestyleOpacity = 1;
$rootScope.shapestyleFillColor = "#fff";
$rootScope.shapestyleborderColor = "black";
$rootScope.shapestyleborderWidth = 2;
$rootScope.shapestyleborderStyles = "solid";
//$rootScope.errorMessage = ''; // Commented initialization to retain message when coming to login after password reset success screen
$("#fileMenuAnchor").addClass("disableFileMenu");
$rootScope.userLicenseInfo = {
userLicenseId: 0,
licenseeAccountNumber: null
};
$rootScope.userData;
$rootScope.userModules;
$rootScope.passwordMismatchMessage;
$rootScope.isVisibleLogin;
$rootScope.haveRoleAdmin;
$rootScope.checked = false;
var isfilloptionChecked = "";
var isOutlineOptionChecked = "";
$rootScope.OpenMyPicture = function () {
$rootScope.CloseListManager();
$rootScope.CloseAnnotationTool();
// close list if opened in DA
var searchedTermListPopUp = $("#HomeContainerDiv").find("div[id*='searchedTermListPopUp']");
for (var i = 0 ; i < searchedTermListPopUp.length; i++) {
var windowviewid = (searchedTermListPopUp[i].id).split('_')[1];
$('#searchedTermListPopUp_' + windowviewid).css('display', 'none');
$('#searchedTermListPopUp_' + windowviewid).css("visibility", "hidden");
$('#searchTermListUl_' + windowviewid).empty();
}
var fileupload = document.getElementById("myPictureFile");
$timeout(function () {
$(fileupload).trigger('click');
}, 300);
$(fileupload).val('');//old file path
fileupload.onchange = function (e) {
var fileId, file, objFileRead;
if (typeof window.FileReader !== 'function') {
$rootScope.errorMessage = "The file API isn't supported on this browser yet.";
$("#messageModal").modal('show');
return;
}
fileId = document.getElementById('myPictureFile');
if (!fileId) {
$rootScope.errorMessage = "File couldn't find the element.";
$("#messageModal").modal('show');
}
else if (!fileId.files) {
$rootScope.errorMessage = "This browser doesn't seem to support the `files` property of file inputs.";
$("#messageModal").modal('show');
}
else if (!fileId.files[0]) {
$rootScope.errorMessage = "Please select a file before clicking 'Load'.";
$("#messageModal").modal('show');
}
else {
file = fileId.files[0];
var extension = file.name.split(".")[1];
if (extension == "jpg" || extension == "jpeg" || extension == "png") {
var reader = new FileReader();
reader.onloadend = function () {
//set default module data
var PicOpenData = {
"mType": 'MY_PICTURES',
"imageSource":reader.result,
"windowTitle": file.name.split(".")[0],
"size": { height: 500, width: 800 },
"position": { x: 300, y: 110 }
};
AIAModuleOpenResourceInfo(PicOpenData);
}
if (file) {
reader.readAsDataURL(file);
}
}
else
{
$rootScope.errorMessage = "Please select a file format type jpg/jpeg or png.";
$("#messageModal").modal('show');
}
}
};
}
$rootScope.OpenMyAnimation = function () {
$rootScope.CloseListManager();
$rootScope.CloseAnnotationTool();
// close list if opened in DA
var searchedTermListPopUp = $("#HomeContainerDiv").find("div[id*='searchedTermListPopUp']");
for (var i = 0 ; i < searchedTermListPopUp.length; i++) {
var windowviewid = (searchedTermListPopUp[i].id).split('_')[1];
$('#searchedTermListPopUp_' + windowviewid).css('display', 'none');
$('#searchedTermListPopUp_' + windowviewid).css("visibility", "hidden");
$('#searchTermListUl_' + windowviewid).empty();
}
var fileupload = document.getElementById("myAnimationFile");
$timeout(function () {
$(fileupload).trigger('click');
}, 300);
$(fileupload).val('');//old file path
fileupload.onchange = function (e) {
var fileId, file, objFileRead;
if (typeof window.FileReader !== 'function') {
$rootScope.errorMessage = "The file API isn't supported on this browser yet.";
$("#messageModal").modal('show');
return;
}
fileId = document.getElementById('myAnimationFile');
if (!fileId) {
$rootScope.errorMessage = "File couldn't find the element.";
$("#messageModal").modal('show');
}
else if (!fileId.files) {
$rootScope.errorMessage = "This browser doesn't seem to support the `files` property of file inputs.";
$("#messageModal").modal('show');
}
else if (!fileId.files[0]) {
$rootScope.errorMessage = "Please select a file before clicking 'Load'.";
$("#messageModal").modal('show');
}
else {
file = fileId.files[0];
var extension = file.name.split(".")[1];
if (extension == "mp4" && file.type=="video/mp4") {
if (file.size <= $rootScope.MaxOneFileSize) {
var reader = new FileReader();
reader.onloadend = function () {
var date = new Date();
var animationId = date.getTime();
//set default module data
var AniOpenData = {
"mType": 'MY_ANIMATIONS',
"id":animationId,//user for identify resource until save or export cb
"videoSource":reader.result,
"windowTitle": file.name.split(".")[0],
"size": { height: 500, width: 800 },
"position": { x: 300, y: 110 }
};
AIAModuleOpenResourceInfo(AniOpenData);
}
if (file) {
reader.readAsDataURL(file);
}
}
else
{
$rootScope.errorMessage = "This Animation video size not allow more than 10MB.Please try again.";
$("#messageModal").modal('show');
}
}
else
{
$rootScope.errorMessage = "This Animation video is not in supported format.Please try again.";
$("#messageModal").modal('show');
}
}
};
}
$rootScope.openResource = function () {
$rootScope.CloseListManager();
$rootScope.CloseAnnotationTool();
// close list if opened in DA
var searchedTermListPopUp = $("#HomeContainerDiv").find("div[id*='searchedTermListPopUp']");
for (var i = 0 ; i < searchedTermListPopUp.length; i++) {
var windowviewid = (searchedTermListPopUp[i].id).split('_')[1];
$('#searchedTermListPopUp_' + windowviewid).css('display', 'none');
$('#searchedTermListPopUp_' + windowviewid).css("visibility", "hidden");
$('#searchTermListUl_' + windowviewid).empty();
}
$('#dvOpenResoucePanel').css('display', 'block');
// var homepath = $location.protocol() + "//" + $location.host() + ":" + $location.port() + "/";
var homepath = $rootScope.homeURL;
$("#HomeContainerDiv").css({ "display": "none", "pointer-events": "none", "opacity": ".5" });
$(".navbar-fixed-top").css({"display": "none", "pointer-events": "none", "opacity": ".5" });
// if any panel in minimized mode
$("#jsPanel-min-container").css({"display":"none"});
var parentslag = "";
var openNewlink = "";
if ($location.url() == "/curriculum-builder") {
parentslag = "curriculum-builder";
openNewlink = "curriculum-builder";
}
else if ($location.url() == "/curriculum-builder-detail") {
parentslag = "curriculum-builder-detail"
openNewlink = "curriculum-builder";
}
else if (($location.url() == "/da-body-view")) {
parentslag = "da-body-view";
openNewlink = "da-view-list";
}
else if ($location.url() == "/clinical-illustrations-detail") {
parentslag = "clinical-illustrations-detail"
openNewlink = "clinical-illustrations";
}
else if ($location.url() == "/module-item-view") {
parentslag = "module-item-view";
openNewlink = "tile-view-list";
}
else if ($location.url() == "/clinical-animations-detail") {
parentslag = "clinical-animations-detail";
openNewlink = "clinical-animations";
}
else if ($location.url() == "/adam-images-detail") {
parentslag = "adam-images-detail";
openNewlink = "ADAM-images";
}
else if ($location.url() == "/3d-anatomy-details") {
parentslag = "3d-anatomy-details";
openNewlink = "3d-anatomy-list";
}
else if ($location.url() == "/lab-exercise-view") {
parentslag = "lab-exercise-view";
openNewlink = "lab-exercises";
}
$.jsPanel({
id: 'dvOpenResourcePanel',
selector: '#dvOpenResoucePanel',
theme: 'success',
currentController: 'HomeController',
parentSlug: parentslag,
content: '
' +
'
',
title: "",
position: {
top: 1,
left: 1
},
controls: { buttons: 'closeonly' },
draggable: "disabled",
size: {
width: screen.width-10,
height: screen.height-150
},
});
}
$scope.OpenResourcePanel = function (iframe) {
var canvasDIvHeight = $("#dvOpenResourcePanel .jsPanel-content").height();
$('#OpenModuleInCB').css('height', canvasDIvHeight);
//var iframe = document.getElementById('OpenModuleInCB');
var innerDoc = (iframe.contentDocument) ? iframe.contentDocument : iframe.contentWindow.document;
var head = $(innerDoc).contents().find("head");
if (head != undefined && head != null)
{
$scope.loadopenresourceContent(head, iframe);
}
else
{
$timeout(function () {
var head = $(innerDoc).contents().find("head");
$scope.loadopenresourceContent(head, iframe);
}, 500);
}
}
$scope.loadopenresourceContent = function (header, iframe)
{
//disable link
var css = '';
var storefunc = '';
$(header).append(css);
$(header).append(storefunc);
$timeout(function () {
// var elmnt = iframe.contentWindow.document.getElementById("da-view-list");
//$('#' + elmnt.id).trigger('click');
sessionStorage.setItem('isModuleOpenByOpenResource', 'true');
sessionStorage.removeItem('ExitsCBFileDetail');
OpenDefaultModule(iframe);
}, 500);
}
$scope.AIAModuleOpenResourceInfo = function (newWindowData)
{
$timeout(function () {
if(newWindowData.mType=="cbFileData")
{ // when override exist cb
$rootScope.isCallFromOtherModule = false;
sessionStorage.setItem("ExitsCBFileDetail", JSON.stringify(newWindowData));
$location.url('/curriculum-builder');
return;
}
$rootScope.isCallFromOtherModule = true;
if ($location.url() != "/curriculum-builder-detail") {
var newwindowNo = 0;
var ExistData = ModuleService.getModuleData(newWindowData.mType);
if (ExistData != undefined && ExistData.length > 0) {
newwindowNo = newwindowNo + ExistData.length;
// clear module type data before open new module
ModuleService.ClearWinDataByModule(newWindowData.mType);
}
ModuleService.setModuleData(newWindowData, newwindowNo);
}
if ($location.url() == "/curriculum-builder-detail") {
window.parent.AIAModuleOpenResoureInCB(newWindowData);
}
else if (($location.url() == "/da-body-view")) {
$scope.loadOpenResourceWindow(newWindowData.mType, '#daBodyview');
}
else if ($location.url() == "/clinical-illustrations-detail") {
$scope.loadOpenResourceWindow(newWindowData.mType, '#CIView');
}
else if ($location.url() == "/module-item-view") {
$scope.loadOpenResourceWindow(newWindowData.mType, '#aaBodyView');
}
else if ($location.url() == "/clinical-animations-detail") {
$scope.loadOpenResourceWindow(newWindowData.mType, '#CAView');
}
else if ($location.url() == "/adam-images-detail") {
$scope.loadOpenResourceWindow(newWindowData.mType, '#AIView');
}
else if ($location.url() == "/3d-anatomy-details") {
$scope.loadOpenResourceWindow(newWindowData.mType, '#ThreeDView');
}
else if ($location.url() == "/lab-exercise-view") {
$scope.loadOpenResourceWindow(newWindowData.mType, '#labBodyview');
}
}, 500);
}
$scope.loadOpenResourceWindow = function (moduleName,BasemoduleDivId)
{
switch (moduleName) {
case "DISSECTIBLE_ANATOMY":
var daSectionExist = document.getElementById('daCustomModuleDiv');
if (daSectionExist == null && BasemoduleDivId != "#daBodyview") {
$(BasemoduleDivId).append($('
'));
var html = $('#daCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another DA module
$rootScope.openDABodyViewMain();
}
break;
case "ATLAS_ANATOMY":
var aaSectionExist = document.getElementById('aaCustomModuleDiv');
if (aaSectionExist == null && BasemoduleDivId != "#aaBodyView") {
$(BasemoduleDivId).append($('
'));
var html = $('#aaCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another AA module
$rootScope.openAAModuleItemMain();
}
break;
case "CLINICAL_ILLUSTRATIONS":
var ciSectionExist = document.getElementById('ciCustomModuleDiv');
if (ciSectionExist == null && BasemoduleDivId != "#CIView") {
$(BasemoduleDivId).append($('
'));
var html = $('#ciCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another CI module
$rootScope.openCIBodyViewMain();
}
break;
case "ADAM_IMAGES":
var aiSectionExist = document.getElementById('aiCustomModuleDiv');
if (aiSectionExist == null && BasemoduleDivId != "#AIView") {
$(BasemoduleDivId).append($('
'));
var html = $('#aiCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another AI module
$rootScope.OpenAdamImageViewMain();
}
break;
case "CLINICAL_ANIMATIONS":
var caSectionExist = document.getElementById('caCustomModuleDiv');
if (caSectionExist == null && BasemoduleDivId != "#CAView") {
$(BasemoduleDivId).append($('
'));
var html = $('#caCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another CA module
$rootScope.openCABodyViewMain();
}
break;
case "THREE_D_ANATOMY":
var threeDSectionExist = document.getElementById('theeDCustomModuleDiv');
if (threeDSectionExist == null && BasemoduleDivId != "#ThreeDView") {
$(BasemoduleDivId).append($('
'));
var html = $('#theeDCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another 3d module
$rootScope.Open3DModelBodyMain();
}
break;
case "LAB_EXERCISE":
var labSectionExist = document.getElementById('labCustomModuleDiv');
if (labSectionExist == null && BasemoduleDivId != "#labBodyview") {
$(BasemoduleDivId).append($('
'));
var html = $('#labCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another 3d module
$rootScope.InitializeLabExerciseMain();
}
break;
case "MY_PICTURES":
var picSectionExist = document.getElementById('picCustomModuleDiv');
if (picSectionExist == null ||picSectionExist==undefined) {
$(BasemoduleDivId).append($('
'));
var html = $('#picCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another picture
$rootScope.OpenMyPictureViewMain();
}
break;
case "MY_ANIMATIONS":
var vidSectionExist = document.getElementById('vidCustomModuleDiv');
if (vidSectionExist == null ||vidSectionExist==undefined) {
$(BasemoduleDivId).append($('
'));
var html = $('#vidCustomModuleDiv').append("
");
$compile(html)($scope);
}
else {
// open another Animation
$rootScope.OpenMyAnimationViewMain();
}
break;
}
}
$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.promptUserForCookies = function () {
$rootScope.errorMessage = AIAConstants.COOKIES_MESSAGE;
$("#messageModal").modal('show');
}
$scope.helpTopicLink = function () {
var x = $location.absUrl();
var pos = x.lastIndexOf($location.url());
$rootScope.homeURL =x.substring(0,pos+1);
var hTopicUrl = $rootScope.homeURL + "content/help/index.html";
var aboutADAM = $rootScope.homeURL + "content/help/about/Adam_Credits_AIA5.html";
$("#helplinkId").append("
Help Topics ");
$("#helplinkId").append("
Customer Support ");
$("#helplinkId").append("
");
$("#helplinkId").append("
About A.D.A.M. ");
}
$scope.DisableDemoAccountOption=function()
{
//enable export image for instructors edition and for superadmin .disable for demo/test user
if ((($rootScope.userData.EditionId == 1) || ($rootScope.userData.EditionId == 2) || ($rootScope.userData.EditionId == 0)) && ($rootScope.userData.UserTypeId != 8)) {
}
else
{
//disable for demo user
$('#exportImageAnchor').addClass('exportImage');
$('#newCurriculumid').addClass('newCurriculum');
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
}
}
$rootScope.initializeAIA = function () {
var url = $location.url();
//some time value not remove then reload
sessionStorage.removeItem('isModuleOpenByOpenResource');
sessionStorage.removeItem('ExitsCBFileDetail');
$('#login').css('visibility', 'visible');
$rootScope.checkRefreshButtonClick = 1;
var date = new Date();
$rootScope.userInfo = {
username: null,
password: null,
emailId: null,
newPassword: null,
confirmPassword: null,
userMessage: null,
unblockUser: false,
isMailForForgotPassword: false,
SessionId:date.getTime()
};
$rootScope.siteUrlInfo = {
siteIP: null,
remoteIPAddress: null,
status: null,
accountNumber: null,
edition: null,
urlReferer: null,
calsCreds: null,
userId: null,
password: null,
mtype:null,
id:null,
SessionId:date.getTime()
}
if (params != null && params != undefined && params != "") {
$scope.ValidateClientSiteUrl();
}
else {
if (navigator.cookieEnabled) {
$rootScope.isLoading = false;
$rootScope.isLoginLoading = false;
//unblock user
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;
//get user is already loggedin or not
$scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
if ($scope.currentUserDetails != undefined) {
$rootScope.isVisibleLogin = false;
$location.url('/');
ConfigurationService.getCofigValue()
.then(
function (configresult) {
$rootScope.current_year = configresult.current_year;
$rootScope.aiaIdleTime = configresult.idleTime;
$rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
$rootScope.aiaPingInterval = configresult.pingInterval;
$rootScope.aiaAnimationPath = configresult.serverPath;
$rootScope.MaxOneFileSize = configresult.fileSize;
var loggedInUser = JSON.parse($scope.currentUserDetails);
//incase site user login userid is 0 so then using license id
//logout site user while reload url without parameter
var userId=loggedInUser.Id==0?loggedInUser.LicenseId:loggedInUser.Id;
$scope.checkuserstatus = {
userId: userId,
tagName: loggedInUser.Id==0?'logout':'update',
SessionId:loggedInUser.SessionId
}
// this case found when browser closed by user after login. after long time (after 20 min) open site again
// loggedInUserDetails contain user detail so user auto login but it is logout by
// 1.by agent job 2. or by admin section from db
// so check user session again before auto login
AuthenticationService.ManageUserLoginStatus($scope.checkuserstatus)
.then(
function (loginStatus) {
if(loginStatus!=null)
{
if(loginStatus=='False')
{
$rootScope.LogoutUserSession();
}
else
{
AuthenticateAlreadyLoggedInUser();
}
}
}),
function (error) {
console.log(' Error in user login status = ' + error.statusText);
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
});
}
var isRememberChecked = $rootScope.getLocalStorageValue('isRememberMeChecked');
if ($rootScope.getLocalStorageValue('isRememberMeChecked') != "" && sessionStorage.getItem("loginSession") == null) {
sessionStorage.setItem("loginSession", "true");
}
if (isRememberChecked == "true" && sessionStorage.getItem("loginSession") == "true" && $rootScope.isVisibleLogin == true) {
$timeout(function () {
$rootScope.userInfo = { username: $rootScope.getLocalStorageValue('RememberMeLoginId'), password: $rootScope.getLocalStorageValue('RememberMePassword'), rememberChk: true };
}, 800);
}
}
}
else {
$rootScope.isVisibleLogin = true;
$rootScope.promptUserForCookies();
}
$scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
if ($scope.currentUserDetails == undefined) {
$rootScope.getConfigurationValues();
}
}
$timeout(function () {
$scope.helpTopicLink();
}, 2000);
}
$rootScope.getConfigurationValues = function () {
ConfigurationService.getCofigValue()
.then(
function (configresult) {
$rootScope.current_year = configresult.current_year;
$rootScope.aiaIdleTime = configresult.idleTime;
$rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
$rootScope.aiaPingInterval = configresult.pingInterval;
$rootScope.aiaAnimationPath = configresult.serverPath;
$rootScope.MaxOneFileSize = configresult.fileSize;
});
}
$rootScope.LoginEnableUI=function()
{
$rootScope.isLoginLoading = false;
$('#spinnerLogin').css('visibility', 'hidden');
$('.loginPanel').css('pointer-events', 'auto');
$('.loginPanel').css('opacity', '1');
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
$('#HomeContainerDiv').css('pointer-events', 'auto');
$('#HomeContainerDiv').css('opacity', '1');
}
$rootScope.LoginDisableUI=function()
{
$rootScope.isLoginLoading = true;
$('#spinnerLogin').css('visibility', 'visible');
$('.loginPanel').css('pointer-events', 'none');
$('.loginPanel').css('opacity', '0.7');
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
$('#HomeContainerDiv').css('pointer-events', 'none');
$('#HomeContainerDiv').css('opacity', '0.7');
}
$rootScope.AuthenticateUser = function (userInfo) {
if (navigator.cookieEnabled) {
$rootScope.errorMessage = "";
if (userInfo.username == "" || userInfo.username == null || userInfo.username == undefined || userInfo.password == "" || userInfo.password == null || userInfo.password == undefined) {
$rootScope.errorMessage = LoginMessageConstants.USER_CREDENTIALS_MISSING;
$("#messageModal").modal('show');
}
else {
$rootScope.LoginDisableUI();
AuthenticationService.authenticateUser(userInfo)
.then(
function (result) {
if (result == LoginConstants.USER_NOT_FOUND) {
$rootScope.LoginEnableUI();
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = LoginMessageConstants.INVALID_USER;
$("#messageModal").modal('show');
}
else {
// birendra// initialize exp img detail object
$rootScope.initializeUserForExportImage(result.Id);
// update result with session detail
result.aiaIdleTime=$rootScope.aiaIdleTime;
result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut;
result.aiaPingInterval=$rootScope.aiaPingInterval;
result.SessionId=userInfo.SessionId;
//display user name
$rootScope.userName=result.FirstName+" "+result.LastName;
//code for modesty setting
if (result.LicenseInfo != null) {
if (result.userselectedModesty == undefined || result.userselectedModesty == null ||
result.userSelectedSkintone == undefined || result.userSelectedSkintone == null) {
if (result.IsModestyOn) {
$rootScope.isModestyOn = true;
$rootScope.isModestyOff = false;
localStorage.setItem("globalModesty", "Y");
$rootScope.formsetting = {
ethnicity: null,
modesty: "Y"
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
else {
$rootScope.isModestyOn = false;
$rootScope.isModestyOff = true;
localStorage.setItem("globalModesty", "N");
$rootScope.formsetting = {
ethnicity: null,
modesty: "N"
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
}
else {
localStorage.setItem("globalModesty", result.userselectedModesty);
localStorage.setItem("globalEthnicity", result.userSelectedSkintone);
$rootScope.formsetting = {
ethnicity: result.userSelectedSkintone,
modesty: result.userselectedModesty
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
}
else {
if (result.userselectedModesty == undefined || result.userselectedModesty == null ||
result.userSelectedSkintone == undefined || result.userSelectedSkintone == null) {
$rootScope.isModestyOn = true;
$rootScope.isModestyOff = false;
localStorage.setItem("globalModesty", "Y");
$rootScope.formsetting = {
ethnicity: null,
modesty: "Y"
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting);
}
else {
localStorage.setItem("globalModesty", result.userselectedModesty);
localStorage.setItem("globalEthnicity", result.userSelectedSkintone);
$rootScope.formsetting = {
ethnicity: result.userSelectedSkintone,
modesty: result.userselectedModesty
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
}
//code for modesty setting
$rootScope.aiaModesty = $rootScope.formsetting.modesty;
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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$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.LoginEnableUI();
$rootScope.errorMessage = LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else {
//LicenseId would be zero for admin that is why we set the haveRoleAdmin = true
if (result.LicenseId == 0 && result.IsActive) {
// set license id -1 for admin
$scope.UpdateUserExportImageData(result.Id, 'LicenseId', -1)
// set enable export image for admin
$scope.UpdateUserExportImageData(result.Id, 'isExportImage', true);
$rootScope.haveRoleAdmin = true;
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
if (isCommingSoonModel == true) {
// ShowAssignedModulesPopup(result.Modules);
if (userInfo.rememberChk) {
$scope.saveRemeberMeDetails(result, userInfo);
}
sessionStorage.setItem("loginSession", "true");
localStorage.setItem('isCommingSoonModel', false);
$rootScope.isVisibleLogin = false;
}
$location.path('/');
$timeout(function () {
$rootScope.LoginEnableUI();
$scope.RedirectToModule();
}, 100);
}
else
{
//1. set haveRoleAdmin = false because LicenseInfo is not null
if (result.LicenseTypeId != 5) {
$rootScope.haveRoleAdmin = true;
}
if (result.UserTypeId == 8) {
$rootScope.haveRoleAdmin = false;
}
if (result.LicenseInfo != null) {
// set license id
$scope.UpdateUserExportImageData(result.Id, 'LicenseId', result.LicenseId)
// set license type :note 5 for demo/test license
$scope.UpdateUserExportImageData(result.Id, 'LicenseTypeId', result.LicenseInfo.LicenseTypeId);
if (result.UserExportImageDetail != null) {
// set already export image count
$scope.UpdateUserExportImageData(result.Id, 'CountExportImage', result.UserExportImageDetail.CountExportedImage);
// set Image limit
$scope.UpdateUserExportImageData(result.Id, 'ExptImageLimit', result.UserExportImageDetail.ExptImageLimit);
// set is enable for export image
$scope.UpdateUserExportImageData(result.Id, 'isExportImage', result.UserExportImageDetail.isExportImage);
}
if (result.LicenseInfo.IsTermAccepted) {
//0.
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
//only instructor allowed to change modesty
//concurrent user of non-instructor
if( result.UserTypeId == 6 && result.EditionId!=1 && result.EditionId!=2)
{
$("#modestyDiv").css("pointer-events", "none");
$("#modestyDiv").css("opacity", 0.5);
$("#modestyDiv").find("*").prop('disabled', true);
}
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
// 3.ShowAssignedModulesPopup
//isCommingSoonModel =true only when user comes first time on application and login
if (isCommingSoonModel == true) {
// ShowAssignedModulesPopup(result.Modules);
}
//4.
if ($scope.rememberChk) {
$scope.saveRemeberMeDetails(result, userInfo);
}
//5.
sessionStorage.setItem("loginSession", "true");
$rootScope.isVisibleLogin = false;
//6. reset the isCommingSoonModel to false in local storage so that upcomming module pop up would not show again to the user after firts time
localStorage.setItem('isCommingSoonModel', false);
// for reseller type user first need to update profile
if (result.UserTypeId == 7 && (result.FirstName == "" || result.EmailId == "" || result.LastName == "")) {
$rootScope.LoginEnableUI();
$('#updateprofile').html(LoginMessageConstants.USER_UPDATE_PROFILE);
$("#profileUpdateModal").modal('show');
$(".modal-backdrop").css("opacity", ".5");
}
else {
$location.path('/');
$timeout(function () {
$rootScope.LoginEnableUI();
$scope.RedirectToModule();
}, 100);
}
}
else {
if ($('#dvTerms').length > 0) {
$('#dvTerms').html(result.TermsAndConditionsText);
}
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$('#dvTermCondition').fadeIn();
$rootScope.userData = result;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
$location.path('/');
}
}
}
// set user session time
$rootScope.loadUserSession();
$rootScope.LoginEnableUI();
}
}
}
}),
function (error) {
console.log(' Error in authentication = ' + error.statusText);
$rootScope.LoginEnableUI();
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
}
}
else {
$rootScope.promptUserForCookies();
}
}
$scope.RedirectToModule = function () {
if($rootScope.siteUrlInfo.mtype!=null)
{
if($rootScope.siteUrlInfo.mtype.toLowerCase()=='ca')
{
$('#clinical-animations').trigger('click');
}
}
if ((localStorage.getItem("daDataObject")) != '') {
//$rootScope.cernerIntegrationActive=true;
// $('#da-view-list').trigger('click');
}
}
$scope.ValidateClientSiteUrl = function () {
$rootScope.isCallFromSite = true;
var siteInfo = params.split('&');
for (var i = 0; i < siteInfo.length; i++) {
if (isCalsCredantialForSIte.toLowerCase() == "true") {
$rootScope.IsCalsCred = true;
}
if (isCalsCredantialForSIte == "True") {
var paramInfo = siteInfo[i].split('=');
//added by birendra direct open CA module
if(paramInfo[0].toLowerCase() == 'mtype')
{
$rootScope.siteUrlInfo.mtype = paramInfo[1];
console.log("$rootScope.siteUrlInfo.mtype" + $rootScope.siteUrlInfo.mtype);
}
else if (paramInfo[0].toLowerCase() == 'id') {
$rootScope.siteUrlInfo.id = paramInfo[1];
console.log("$rootScope.siteUrlInfo.id" + $rootScope.siteUrlInfo.id);
}
else if (paramInfo[0].toLowerCase() == 'username') {
$rootScope.siteUrlInfo.userId = paramInfo[1];
console.log("$rootScope.siteUrlInfo.username" + $rootScope.siteUrlInfo.userId);
}
else if (paramInfo[0].toLowerCase() == 'accountnumber') {
$rootScope.siteUrlInfo.accountNumber = paramInfo[1];
console.log("$rootScope.siteUrlInfo.accountNumber" + $rootScope.siteUrlInfo.accountNumber);
}
// if (paramInfo[0] == 'calsCredantial') {
// $rootScope.siteUrlInfo.calsCreds = paramInfo[1];
// console.log("$rootScope.siteUrlInfo.calsCreds" + $rootScope.siteUrlInfo.calsCreds);
// }
// else if (paramInfo[0] == 'username') {
// $rootScope.siteUrlInfo.username = paramInfo[1];
// console.log("$rootScope.siteUrlInfo.username" + $rootScope.siteUrlInfo.username);
// }
// else if (paramInfo[0] == 'password') {
// $rootScope.siteUrlInfo.password = paramInfo[1];
// console.log("$rootScope.siteUrlInfo.password " + $rootScope.siteUrlInfo.password);
// }
//$rootScope.userInfo.username = $rootScope.siteUrlInfo.userId;
//$rootScope.userInfo.password = $rootScope.siteUrlInfo.password;
}
else {
var paramInfo = siteInfo[i].split('=');
if (paramInfo[0] == 'siteIP') {
$rootScope.siteUrlInfo.siteIP = paramInfo[1];
console.log("$rootScope.siteUrlInfo.siteIP=" + $rootScope.siteUrlInfo.siteIP);
}
else if (paramInfo[0] == 'accountNumber') {
$rootScope.siteUrlInfo.accountNumber = paramInfo[1];
console.log("$rootScope.siteUrlInfo.accountNumber=" + $rootScope.siteUrlInfo.accountNumber);
}
else if (paramInfo[0] == 'edition') {
$rootScope.siteUrlInfo.edition = paramInfo[1];
console.log("$rootScope.siteUrlInfo.siteIP=" + $rootScope.siteUrlInfo.siteIP);
}
else if (paramInfo[0] == 'urlReferer') {
$rootScope.siteUrlInfo.urlReferer = paramInfo[1];
console.log("$rootScope.siteUrlInfo.urlReferer" + $rootScope.siteUrlInfo.urlReferer);
}
else if (paramInfo[0] == 'remoteIPAddress') {
$rootScope.siteUrlInfo.remoteIPAddress = paramInfo[1];
console.log("$rootScope.siteUrlInfo.remoteIPAddress" + $rootScope.siteUrlInfo.remoteIPAddress);
}
localStorage.setItem("siteUrlInfo", JSON.stringify($rootScope.siteUrlInfo));
}
}
if (isCalsCredantialForSIte == "True") {
if($rootScope.siteUrlInfo.mtype!=null && $rootScope.siteUrlInfo.mtype.toLowerCase()=='ca' && $rootScope.siteUrlInfo.userId!=null && $rootScope.siteUrlInfo.accountNumber!=null)
{
$rootScope.LoginDisableUI();
var userInfo=$rootScope.userInfo;//also get session id
AuthenticationService.ByPassLoginToOpenModule($rootScope.siteUrlInfo)
.then(
function (result) {
if(result!=null)
{
$scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
ConfigurationService.getCofigValue()
.then(
function (configresult) {
$rootScope.current_year = configresult.current_year;
$rootScope.aiaIdleTime = configresult.idleTime;
$rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
$rootScope.aiaPingInterval = configresult.pingInterval;
$rootScope.aiaAnimationPath = configresult.serverPath;
$rootScope.MaxOneFileSize = configresult.fileSize;
userInfo.username = result.LoginId;
userInfo.password = result.Password;
var loggedInUser = JSON.parse($scope.currentUserDetails);
if(loggedInUser!==null && loggedInUser.LoginId==result.LoginId)
{
//using old session id
userInfo.SessionId = loggedInUser.SessionId;
$rootScope.AuthenticateUser(userInfo);
}
else
{
//using new sessionid
$rootScope.AuthenticateUser(userInfo);
}
});
}
}),
function (error) {
console.log(' Error in bypass login = ' + error.statusText);
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
}
else
{
console.log(' invalid detail in bypass login');
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = "authentication is not allowed due to invalid details format .\nPlease pass the correct details again!";
$("#messageModal").modal('show');
}
}
else {
console.log($rootScope.siteUrlInfo);
$rootScope.LoginDisableUI();
$scope.currentUserDetails = $rootScope.getLocalStorageValue('loggedInUserDetails');
var sitedetail=$rootScope.siteUrlInfo;
ConfigurationService.getCofigValue()
.then(
function (configresult) {
$rootScope.current_year = configresult.current_year;
$rootScope.aiaIdleTime = configresult.idleTime;
$rootScope.aiaIdleTimeOut = configresult.idelTimeOut;
$rootScope.aiaPingInterval = configresult.pingInterval;
$rootScope.aiaAnimationPath = configresult.serverPath;
$rootScope.MaxOneFileSize = configresult.fileSize;
var loggedInUser = JSON.parse($scope.currentUserDetails);
//check already login by account number bcz no login id for site login
//maintain user session by licenseid of site login
if(loggedInUser!==null && loggedInUser.AccountNumber==sitedetail.accountNumber)
{
//using old session id
sitedetail.SessionId = loggedInUser.SessionId;
$rootScope.AuthenticateClientSiteUser(sitedetail);
}
else
{
//using new sessionid
$rootScope.AuthenticateClientSiteUser(sitedetail);
}
});
}
}
$rootScope.AuthenticateClientSiteUser = function (siteInfo) {
$rootScope.LoginDisableUI();
AuthenticationService.validateClientSite(siteInfo)
.then(
function (result) {
console.log(result);
if (result != null) {
console.log(result);
if (result == LoginConstants.INVALID_CLIENT) {
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = LoginConstants.INVALID_CLIENT;
$("#messageModal").modal('show');
}
else if (result == LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER) {
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER;
$("#messageModal").modal('show');
}
else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_ACCOUNT_NUMBER_NOT_NULL) {
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = LoginMessageConstants.E_ACCOUNT_NUMBER_NOT_NULL;
$("#messageModal").modal('show');
}
else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_ID_NOT_NULL) {
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = LoginMessageConstants.E_EDITION_ID_NOT_NULL;
$("#messageModal").modal('show');
}
else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_NOT_LINKED_WITH_SITE) {
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = LoginMessageConstants.E_EDITION_NOT_LINKED_WITH_SITE;
$("#messageModal").modal('show');
}
else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.LICENSE_INACTIVE) {
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$rootScope.errorMessage = LoginMessageConstants.LICENSE_INACTIVE_MESSAGE;
$("#messageModal").modal('show');
}
else {
// update result with session detail
result.aiaIdleTime=$rootScope.aiaIdleTime;
result.aiaIdleTimeOut=$rootScope.aiaIdleTimeOut;
result.aiaPingInterval=$rootScope.aiaPingInterval;
result.SessionId=siteInfo.SessionId;
//display user name
$rootScope.userName=result.FirstName+" "+result.LastName;
if (typeof result.FirstName != undefined || result.FirstName != "" || result.FirstName != null) {
//code for modesty setting
if (result.LicenseInfo != null) {
if (result.Modesty) {
$rootScope.isModestyOn = true;
$rootScope.isModestyOff = false;
localStorage.setItem("globalModesty", "Y");
$rootScope.formsetting = {
ethnicity: null,
modesty: "Y"
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
else {
$rootScope.isModestyOn = false;
$rootScope.isModestyOff = true;
localStorage.setItem("globalModesty", "N");
$rootScope.formsetting = {
ethnicity: null,
modesty: "N"
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
}
else {
$rootScope.isModestyOn = true;
$rootScope.isModestyOff = false;
localStorage.setItem("globalModesty", "Y");
$rootScope.formsetting = {
ethnicity: null,
modesty: "Y"
}
$rootScope.UpdateAndCloseSetting($rootScope.formsetting)
}
//code for modesty setting
$rootScope.aiaModesty = $rootScope.formsetting.modesty;
$rootScope.siteId = result.siteId;
// birendra// initialize exp img detail object
$rootScope.initializeUserForExportImage(result.Id);
//LicenseId would be zero for admin that is why we set the haveRoleAdmin = true
if (result.LicenseId == 0) {
$rootScope.haveRoleAdmin = true;
// set license id -1 for admin
$scope.UpdateUserExportImageData(result.Id,'LicenseId',-1)
// set enable export image for admin
$scope.UpdateUserExportImageData(result.Id,'isExportImage',true);
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
if (isCommingSoonModel == true) {
ShowAssignedModulesPopup(result.Modules);
sessionStorage.setItem("loginSession", "true");
localStorage.setItem('isCommingSoonModel', false);
$rootScope.isVisibleLogin = false;
}
$location.path('/');
}
else {
if (result.LicenseInfo != null ) {
//only site instructor allowed to change modesty
if(result.EditionId!=1 && result.EditionId!=2)
{
$("#modestyDiv").css("pointer-events", "none");
$("#modestyDiv").css("opacity", 0.5);
$("#modestyDiv").find("*").prop('disabled', true);
}
// set license id
$scope.UpdateUserExportImageData(result.Id, 'LicenseId', result.LicenseId)
// set license type :note 5 for demo/test license
$scope.UpdateUserExportImageData(result.Id, 'LicenseTypeId', result.LicenseInfo.LicenseTypeId);
if(result.UserExportImageDetail!=null)
{
// set already export image count
$scope.UpdateUserExportImageData(result.Id,'CountExportImage',result.UserExportImageDetail.CountExportedImage);
// set Image limit
$scope.UpdateUserExportImageData(result.Id,'ExptImageLimit',result.UserExportImageDetail.ExptImageLimit);
// set is enable for export image
$scope.UpdateUserExportImageData(result.Id,'isExportImage',result.UserExportImageDetail.isExportImage);
}
$rootScope.userData = result;
$rootScope.userModules = result.Modules;
//1. set haveRoleAdmin = false because LicenseInfo is not null
$rootScope.haveRoleAdmin = false;
//2.
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
//5.
sessionStorage.setItem("loginSession", "true");
$rootScope.isVisibleLogin = false;
//6. reset the isCommingSoonModel to false in local storage so that upcomming module pop up would not show again to the user after firts time
// localStorage.setItem('isCommingSoonModel', false);
$location.path('/');
}
else {
if ($('#dvTerms').length > 0) {
$('#dvTerms').html(result.TermsAndConditionsText);
}
$rootScope.isVisibleLogin = true;
$rootScope.LoginEnableUI();
$('#dvTermCondition').fadeIn();
$rootScope.userData = result;
$rootScope.haveRoleAdmin = false;
localStorage.setItem('loggedInUserDetails', JSON.stringify(result));
$location.path('/');
}
}
$rootScope.LoginEnableUI();
// set user session time
$rootScope.loadUserSession();
}
}
}
},
function (error) {
console.log(' Error in authentication = ' + error.statusText);
$rootScope.LoginEnableUI();
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
)
}
$scope.saveRemeberMeDetails = function (result, userInfo) {
localStorage.setItem('RememberMeLoginId', result.LoginId);
localStorage.setItem('RememberMePassword', result.Password);
localStorage.setItem("isRememberMeChecked", userInfo.rememberChk);
}
function ShowAssignedModulesPopup(userModules) {
var allModules = Modules;
var arrPendingModules = [];
if ($('#dvPendingModules').length > 0) {
$('#dvPending').hide();
}
for (var module = 1; module <= allModules.length; module++) {
$('#moduleDiv' + module).hide();
}
if (('#moduleDiv1017').length > 0) {
$('#moduleDiv1017').hide();
}
for (var count = 0; count < userModules.length; count++) {
for (var module = 0; module < allModules.length; module++) {
if (userModules[count].id == allModules[module].Id) {
$('#moduleDiv' + userModules[count].id).show();
break;
}
if (userModules[count].id == 7)
arrPendingModules.push(userModules[count].id);
if (userModules[count].id == 8)
arrPendingModules.push(userModules[count].id);
if (userModules[count].id == 10)
arrPendingModules.push(userModules[count].id);
}
}
if (userModules.length > 0) {
$('#dvUserModulesInfo').modal('show');
}
if (arrPendingModules.length > 0) {
$('#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);;
// for reseller type user first need to update profile
if (userInfo.UserTypeId == 7 && (userInfo.FirstName == "" || userInfo.EmailId == "" || userInfo.LastName == "")) {
$('#updateprofile').html(LoginMessageConstants.USER_UPDATE_PROFILE);
$("#profileUpdateModal").modal('show');
$(".modal-backdrop").css("opacity", ".5");
}
else {
$location.path('/');
}
}
}
}
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.RememberMe = function (isRememberMeChecked) {
if (localStorage.getItem('isRememberMeChecked') != null) {
localStorage.removeItem('loggedInUserDetails');
localStorage.removeItem('isRememberMeChecked');
localStorage.removeItem('RememberMeLoginId');
localStorage.removeItem('RememberMePassword');
}
}
$rootScope.loadUserSession = function () {
//update session config from API
Idle.setIdle($rootScope.aiaIdleTime);
Idle.setTimeout($rootScope.aiaIdleTimeOut);
Keepalive.setInterval($rootScope.aiaPingInterval);
Idle.watch();// start the session
$rootScope.isSessionTimeout=false;
$rootScope.isRedirectToAdmin=false;
$rootScope.userStatus = {
userId: null,
tagName: null,
SessionId:null
}
console.log('user session start');
$rootScope.CheckUserSession('insert');
$rootScope.$on('IdleStart', function() {
// this event fire when idle time finish and time out start
// config set in AIA.js -:IdleProvider.idle(1*30);;
});
$rootScope.$on('IdleEnd', function() {
// this event fires by user activity during timeout period
// it reset idle time and timeout
// config set in AIA.js -:IdleProvider.interrupt('keydown wheel mousedown touchstart touchmove scroll');
});
$rootScope.$on('IdleTimeout', function() {
// this event fire when idle time finished and time out also finished
// config set in AIA.js -:IdleProvider.timeout(15);
$rootScope.isSessionTimeout=true;
console.log('session is timeout');
$rootScope.CheckUserSession('logout');
});
$rootScope.$on('Keepalive', function() {
// it watch the session on perticular time interval during idle time period
// config set in AIA.js -: KeepaliveProvider.interval(10);
//we will use it to recieve request from databse if user logout from admin activity
// console.log('ping user session');
$rootScope.CheckUserSession('update');
});
$window.onbeforeunload = function (e) {
var confirmation = {};
// if($location.url()!= "/") {
if ($rootScope.isSessionTimeout==false && $rootScope.isRedirectToAdmin==false) {
var event = $rootScope.$broadcast('onBeforeUnload', confirmation);
if (event.defaultPrevented) {
return confirmation.message;
}
}
// }
};
}
$rootScope.$on('onBeforeUnload', function (e, confirmation) {
confirmation.message = "All data willl be lost.";
e.preventDefault();
});
$rootScope.LogoutUser = function () {
$rootScope.isSessionTimeout=true;
localStorage.removeItem('loggedInUserDetails');
localStorage.clear();
$rootScope.CheckUserSession('logout');
$timeout(function(){
document.location = '/';
$rootScope.isVisibleLogin = true;
},50);
}
$rootScope.LogoutUserSession = function () {
$rootScope.isSessionTimeout=true;
localStorage.removeItem('loggedInUserDetails');
localStorage.clear();
document.location = '/';
$rootScope.isVisibleLogin = true;
}
$rootScope.CheckUserSession = function (tagName) {
//console.log('user login id: '+$rootScope.userData.Id);
//console.log('user login activity tag: '+tagName);
if($rootScope.userData==undefined) return;
//incase site user login userid is 0 so then using license id
$rootScope.userStatus.userId=$rootScope.userData.Id==0?$rootScope.userData.LicenseId:$rootScope.userData.Id;
$rootScope.userStatus.tagName=tagName;
$rootScope.userStatus.SessionId=$rootScope.userData.SessionId;
AuthenticationService.ManageUserLoginStatus($rootScope.userStatus)
.then(
function (loginStatus) {
if(loginStatus!=null)
{
if(loginStatus=='False')
{
$rootScope.LogoutUserSession();
}
}
}),
function (error) {
console.log(' Error in user login status = ' + error.statusText);
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
}
function AuthenticateAlreadyLoggedInUser() {
isCommingSoonModel = $rootScope.getLocalStorageValue('isCommingSoonModel');
try {
var userInfo = JSON.parse($scope.currentUserDetails);
if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) {
userInfo["username"] = userInfo.LoginId;
userInfo["password"] = userInfo.Password;
$rootScope.AuthenticateUser(userInfo);
}
}
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();
$rootScope.errorMessage = LoginMessageConstants.INCORRECT_EMAIL_ID;
$("#messageModal").modal('show');
}
else if (result == LoginConstants.MAIL_NOT_SENT) {
removeEmailPopUp();
$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
$rootScope.errorMessage = message;
$("#messageModal").modal('show');
}
}
},
function (error) {
console.log(' Error in authentication = ' + error.statusText);
removeEmailPopUp();
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
});
}
else {
removeEmailPopUp();
$rootScope.errorMessage = LoginMessageConstants.INCORRECT_EMAIL_ID;
$("#messageModal").modal('show');
}
}
else {
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) {
$rootScope.errorMessage = LoginMessageConstants.USER_NOT_FOUND;
$("#messageModal").modal('show');
}
else if (result == LoginConstants.EXCEPTION_OCCURED) {
$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) {
$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);
$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.sucessMessage = LoginMessageConstants.USER_UNBLOCK_SUCCESS_MESSAGE;
$("#successMessageModal").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').html($('#lexiconLangDropdown').find('option').sort(function (x, y) {
return $(x).text() > $(y).text() ? 1 : -1
}));
}
});
}
$('#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");
}
$(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');
$('#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');
$('#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' : '';
}
var userInformation = $rootScope.userData;
if (($location.url() == "/da-body-view")) {
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#labExPdfOption").addClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$rootScope.ConvertCurriculum = "newCurriculum";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$("#exportImageAnchor").removeClass("exportImage");
}
else if ($location.url() == "/clinical-illustrations-detail") {
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#labExPdfOption").addClass("disableSubMenu");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$("#optionsListManagerTab").addClass("disableSubMenu");
$("#optiontSetting").addClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.ConvertCurriculum = "newCurriculum";
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$("#exportImageAnchor").removeClass("exportImage");
}
else if ($location.url() == "/module-item-view") {
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#optiontSetting").addClass("disableSubMenu");
$("#labExPdfOption").addClass("disableSubMenu");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.ConvertCurriculum = "newCurriculum";
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$("#exportImageAnchor").removeClass("exportImage");
}
else if ($location.url() == "/clinical-animations-detail") {
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").addClass("disableMenuoption");
$("#labExPdfOption").addClass("disableSubMenu");
$("#annotationToolBarOptions").addClass("disableSubMenu");
$("#optionsListManagerTab").addClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.ConvertCurriculum = "newCurriculum";
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
$("#exportImageAnchor").addClass("exportImage");
}
else if ($location.url() == "/curriculum-builder") {
$("#openResourceId").addClass("openResources");
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").addClass("disableMenuoption");
$("#newCurriculumid").removeClass("newCurriculum");
$rootScope.ConvertCurriculum = "";
$rootScope.openCurriculum = "";
$rootScope.saveCurriculam = "saveCurriculam";
$("#labExPdfOption").addClass("disableSubMenu");
$("#openPictureId").addClass("OpenPitures");
$("#openAnimationId").addClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
$("#exportImageAnchor").addClass("exportImage");
//close while back from cb
$rootScope.CloseAnnotationTool();
$rootScope.CloseListManager();
$scope.DisableDemoAccountOption();
}
else if ($location.url() == "/curriculum-builder-detail") {
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#Menuoptionid").addClass("disableMenuoption");
$("#newCurriculumid").removeClass("newCurriculum");
$rootScope.ConvertCurriculum = "";
$rootScope.openCurriculum = "";
$rootScope.saveCurriculam = "";
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
$("#exportImageAnchor").addClass("exportImage");
$scope.DisableDemoAccountOption();
}
else if ($location.url() == "/adam-images-detail") {
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#labExPdfOption").addClass("disableSubMenu");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$("#optionsListManagerTab").addClass("disableSubMenu");
$("#optiontSetting").addClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.ConvertCurriculum = "newCurriculum";
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$("#exportImageAnchor").removeClass("exportImage");
}
else if ($location.url() == "/3d-anatomy-details") {
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").addClass("disableMenuoption");
$("#labExPdfOption").addClass("disableSubMenu");
$("#annotationToolBarOptions").addClass("disableSubMenu");
$("#optionsListManagerTab").addClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.ConvertCurriculum = "newCurriculum";
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
$("#exportImageAnchor").addClass("exportImage");
}
else if ($location.url() == "/lab-exercise-view") {
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#labExPdfOption").removeClass("disableSubMenu");
$("#annotationToolBarOptions").addClass("disableSubMenu");
$("#optionsListManagerTab").addClass("disableSubMenu");
$("#fileMenuAnchor").removeClass("disableFileMenu");
$("#openResourceId").removeClass("openResources");
$("#openPictureId").removeClass("OpenPitures");
$("#openAnimationId").removeClass("OpenPitures");
$rootScope.disableMenuoption = "disableMenuoption";
$("#newCurriculumid").addClass("newCurriculum");
$rootScope.ConvertCurriculum = "newCurriculum";
$rootScope.openCurriculum = "openCurriculum";
$rootScope.saveCurriculam = "saveCurriculam";
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
$("#exportImageAnchor").addClass("exportImage");
}
else {
$("#fileMenuAnchor").addClass("disableFileMenu");
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").addClass("disableMenuoption");
$rootScope.CloseAnnotationTool();
$rootScope.CloseListManager();
angular.element('#modal-settings').css('display', 'none');
}
});
//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.cBModulejsPanelTop = function () {
var paneltopPosition = 0;
var moduleImagePanel = $("div[id*='ImagePanel']");
if (moduleImagePanel.length > 0) {
for (var j = 0; j < moduleImagePanel.length; j++) {
var ctx = document.getElementById(moduleImagePanel[j].id);
var pTop = ctx.offsetTop + ctx.offsetHeight + 10;
if (paneltopPosition < pTop) {
paneltopPosition = pTop+20;
}
}
}
else {
// first panel
paneltopPosition = 610;
}
return paneltopPosition;
}
$rootScope.disableTopMenuOption=function()
{
$("#annotationButton").addClass("disableMenuoption");
$("#Menuoptionid").addClass("disableMenuoption");
$("#optionsListManagerTab").addClass("disableSubMenu");
$("#annotationToolBarOptions").addClass("disableSubMenu");
$("#optionsCurriculum").addClass("disableSubMenu");
$("#optiontSetting").addClass("disableSubMenu");
$("#labExPdfOption").addClass("disableSubMenu");
$("#printAVAnchor").addClass("PrintViewer");
$("#printAllAVAnchor").addClass("PrintViewer");
$("#printPreviewAnchor").addClass("PrintPreview");
$("#exportImageAnchor").addClass("exportImage");
//disble option popup
$("#listManagerBody *").prop('disabled',true);
}
$rootScope.enableTopMenuOption=function(paneld)
{
if(paneld.match('daImagePanel'))
{
$("#optionsListManagerTab").removeClass("disableSubMenu");
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$("#optiontSetting").removeClass("disableSubMenu");
$("#listManagerBody *").prop('disabled',false);
$('#exportImageAnchor').removeClass('exportImage');
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$rootScope.panelNameWithCb = paneld;
$scope.DisableDemoAccountOption();
}
else if(paneld.match('AAImagePanel'))
{
$("#optionsListManagerTab").removeClass("disableSubMenu");
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$("#listManagerBody *").prop('disabled',false);
$('#exportImageAnchor').removeClass('exportImage');
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$rootScope.panelNameWithCb = paneld;
$scope.DisableDemoAccountOption();
}
else if(paneld.match('aiImagePanel'))
{
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$('#exportImageAnchor').removeClass('exportImage');
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$rootScope.panelNameWithCb = paneld;
$scope.DisableDemoAccountOption();
}
else if(paneld.match('picImagePanel'))
{
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$('#exportImageAnchor').removeClass('exportImage');
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$rootScope.panelNameWithCb = paneld;
$scope.DisableDemoAccountOption();
}
else if(paneld.match('ciImagePanel'))
{
$("#annotationButton").removeClass("disableMenuoption");
$("#Menuoptionid").removeClass("disableMenuoption");
$("#annotationToolBarOptions").removeClass("disableSubMenu");
$('#exportImageAnchor').removeClass('exportImage');
$("#printAVAnchor").removeClass("PrintViewer");
$("#printAllAVAnchor").removeClass("PrintViewer");
$("#printPreviewAnchor").removeClass("PrintPreview");
$rootScope.panelNameWithCb = paneld;
$scope.DisableDemoAccountOption();
}
else if(paneld.match('caImagePanel'))
{
//disable all option
}
else if(paneld.match('labImagePanel'))
{
$("#Menuoptionid").removeClass("disableMenuoption");
$("#labExPdfOption").removeClass("disableSubMenu");
}
else if(paneld.match('ThreeDImagePanel'))
{
//disable all option
}
}
//reset option when load
$rootScope.resetMenuOption = function () {
$timeout(function () {
$rootScope.panelNameWithCb="";
$rootScope.disableTopMenuOption();
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
$rootScope.enableTopMenuOption(paneld);
}
}
}, 500);
}
// enable/disable option Panel click
$rootScope.resetMenuOptionOnClick = function (moduleName) {
$rootScope.panelNameWithCb="";
$rootScope.disableTopMenuOption();
$rootScope.enableTopMenuOption(moduleName);
$rootScope.panelNameWithCb = moduleName;
}
// CB: reset panel top position when if any module closed
$rootScope.resetjsPanelTop = function (panelName) {
$timeout(function () {
var firsttopPosition = 70;
if ($location.url() == "/curriculum-builder-detail") {
firsttopPosition = 680;
}
$rootScope.disableTopMenuOption();
var moduleImagePanel = $("div[id*='ImagePanel']");
if (moduleImagePanel.length > 0) {
for (var index = 0; index < moduleImagePanel.length; index++) {
if (index == 0) {
var panel1 = document.getElementById(moduleImagePanel[index].id);
if (!$(panel1).hasClass("jsPanel-state-minimized")) {
$("#" + panel1.id).css("top", firsttopPosition + 'px');
}
}
else {
var prevpanel = document.getElementById(moduleImagePanel[index - 1].id);
var lastTop = prevpanel.offsetTop + prevpanel.offsetHeight + 10;
var lastpanel = document.getElementById(moduleImagePanel[index].id);
if (!$(lastpanel).hasClass("jsPanel-state-minimized")) {
$("#" + lastpanel.id).css("top", lastTop + 'px');
}
}
//Reset menu option like list manager,annotation when close module
var moduleName = moduleImagePanel[index].id;
$rootScope.enableTopMenuOption(moduleName);
}
}
// list manger already open then refresh it or close
if($('#listManager').css('display') == 'block')
{
$scope.updateListManagerView(panelName);
}
}, 500);
}
$rootScope.openParent = function (slug,actionController) {
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 ($('#aiImagePanel').length > 0)
$('#aiImagePanel').remove();
//if ($('#caVideoPanel').length > 0)
// $('#caVideoPanel').remove();
if ($('#caImagePanel').length > 0)
$('#caImagePanel').remove();
if ($('#ImagePanel').length > 0)
$('#ImagePanel').remove();
if ($location.url() == "/curriculum-builder-detail") {
if(actionController=='CurrBuildController')
{
if($rootScope.UnsaveCurriculum == true)
{
$("#confirmCurriculumModal").modal('show');
$(".modal-backdrop").css("opacity", ".5");
}
else{
//clear cb content data
$rootScope.saveConfirmNo();
}
}
}
else
{
// find all panel in HomeContainerDiv and outside(while minimize);
var modulePanel = $(document).find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
//if only one module left
if(modulePanel.length==1) $location.url('/' + slug);
}
}
}
}
//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) {
if ($rootScope.openViews[i].bodyView == 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 () {
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
$rootScope.isAnnotatiomToolBarPopupActive = true;
$rootScope.isAnnotatiomToolBarPopupClosed = false;
$rootScope.isAnnotaionToolBarDrawingModeActive = false;
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');
}
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');
}
$("#annotationpainteraser").removeAttr('disabled', 'disabled');
$("#OnIdentify").addClass("annotationtoolbartab");
$rootScope.isAnnotationWindowOpen = true;
if(paneld.match("daImagePanel"))
{
$rootScope.daAnnotationToolEvent(MultiWinId);
if ($("#transparencyScale_" + MultiWinId).css("display") == "block") {
$rootScope.switchToTransparencycanvas(paneld);
}
}
else if(paneld.match("AAImagePanel"))
{
$rootScope.aaAnnotationToolEvent(MultiWinId);
var canvasZIndex = $("#canvasAA_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintAA_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#aaDetailViewCanvas_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#aaDetailViewCanvas_' + MultiWinId).css("z-index", canvasZIndex);
}
}
else if(paneld.match("ciImagePanel"))
{
$rootScope.ciAnnotationToolEvent(MultiWinId);
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
else if(paneld.match("aiImagePanel"))
{
$rootScope.aiAnnotationToolEvent(MultiWinId);
}
else if(paneld.match("picImagePanel"))
{
$rootScope.picAnnotationToolEvent(MultiWinId);
}
// var PanelElement= $scope.GetPanelElement(paneld);
// var canvasElement = PanelElement.canvasElement;
// if (canvasElement == undefined) continue;
// $scope.onDrawingCanvasOnModule(canvasElement);
// $scope.removeOnDrawingCanvas(canvasElement);
}
}
$("#annotationTollbar").modal('show');
$(".modal-backdrop").css("z-index", "0");
}
var FontFamilyJson = '~/../content/data/json/settings/fontstyle.json';
if ($rootScope.isFontFamilyLoaded == false) {
DataService.getJson(FontFamilyJson)
.then(
function (result) {
$rootScope.AnnotationFontFamily = result;
for (var i = 0; i <= $rootScope.AnnotationFontFamily.FontFamily.length - 1; i++) {
var fontName = $rootScope.AnnotationFontFamily.FontFamily[i].FontName;
if (/\s/g.test(fontName)) { //Check if white-space exists in between strings
fontName = fontName.replace(" ", "_"); // replace white-space with an underscore
}
//$rootScope.AnnotationFontFamily.FontFamily[i].FontName
$("#selected-font-family").append("
");
}
$rootScope.isFontFamilyLoaded = true;
},
function (error) {
console.log(error.statusText)
}
)}
}
$rootScope.CloseAnnotationTool = function () {
console.log('close');
$rootScope.isAnnotatiomToolBarPopupActive = false;
$rootScope.isAnnotatiomToolBarPopupClosed = true;
$("#OnIdentify").removeClass("annotationtoolbartab");
$("#DrawMode").removeClass("annotationtoolbartab");
$('.btnCursor').removeClass('activebtncolor');
//$(".annotationTollbar").css("display", "none");
$("#annotationTollbar").modal('hide');
$rootScope.isAnnotationWindowClose = true;
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$rootScope.isAnnotaionToolBarDrawingModeActive = false;
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
// remove event listener
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
$scope.removeOnDrawingCanvas(canvasElement);
if (paneld.match("daImagePanel")) {
if ($("#transparencyScale_" + MultiWinId).css("display") == "block") {
$rootScope.switchToTransparencycanvas(paneld);
}
else {
$rootScope.switchCanvas(paneld);
}
}
else {
$rootScope.switchCanvas(paneld);
}
$rootScope.shapeType = '';
if (paneld.match("AAImagePanel")) {
var canvasId="#canvasAA_" + MultiWinId;
var canvasZIndex = $("#canvasAA_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintAA_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#aaDetailViewCanvas_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#aaDetailViewCanvas_' + MultiWinId).css("z-index", canvasZIndex);
}
var aaPinDataArray=$rootScope.GetAAwindowData(MultiWinId,'aaPinData');
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == canvasId) {
for (var j = 0; j <= aaPinDataArray.length - 1; j++) {
if (($rootScope.jcanvasObjectArray[i].x <= parseInt(aaPinDataArray[j]._HeadX) && $rootScope.jcanvasObjectArray[i].y <= parseInt(aaPinDataArray[j]._HeadY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt(aaPinDataArray[j]._HeadX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt(aaPinDataArray[j]._HeadY)) || ($rootScope.jcanvasObjectArray[i].x <= parseInt(aaPinDataArray[j]._PinX) && $rootScope.jcanvasObjectArray[i].y <= parseInt(aaPinDataArray[j]._PinY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt(aaPinDataArray[j]._PinX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt(aaPinDataArray[j]._PinY))) {
var pinName = 'Pin_' + aaPinDataArray[j]._PinId;
var pinArcName = 'PinArc_' + aaPinDataArray[j]._PinId;
$('#aaDetailViewCanvas_' + MultiWinId).setLayer(pinName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
$('#aaDetailViewCanvas_' + MultiWinId).setLayer(pinArcName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
}
}
}
}
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
}
}
}
}
$rootScope.CIAnotationIdentifyModeOff = false;
$rootScope.OnIdentifyClick = function () {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$rootScope.shapeType = "";
$(".btn-annotation").removeClass("activebtncolor");
$("#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;
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
$rootScope.switchCanvas(paneld);
if (paneld.match("daImagePanel")) {
if ($("#transparencyScale_" + MultiWinId).css("display") == "block") {
$rootScope.switchToTransparencycanvas(paneld);
}
}
if (paneld.match("AAImagePanel")) {
var canvasId="#canvasAA_" + MultiWinId;
var canvasZIndex = $("#canvasAA_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintAA_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#aaDetailViewCanvas_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#aaDetailViewCanvas_' + MultiWinId).css("z-index", canvasZIndex);
}
var aaPinDataArray=$rootScope.GetAAwindowData(MultiWinId,'aaPinData');
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == canvasId) {
for (var j = 0; j <= aaPinDataArray.length - 1; j++) {
if (($rootScope.jcanvasObjectArray[i].x <= parseInt(aaPinDataArray[j]._HeadX) && $rootScope.jcanvasObjectArray[i].y <= parseInt(aaPinDataArray[j]._HeadY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt(aaPinDataArray[j]._HeadX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt(aaPinDataArray[j]._HeadY)) || ($rootScope.jcanvasObjectArray[i].x <= parseInt(aaPinDataArray[j]._PinX) && $rootScope.jcanvasObjectArray[i].y <= parseInt(aaPinDataArray[j]._PinY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt(aaPinDataArray[j]._PinX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt(aaPinDataArray[j]._PinY))) {
var pinName = 'Pin_' + aaPinDataArray[j]._PinId;
var pinArcName = 'PinArc_' + aaPinDataArray[j]._PinId;
$('#aaDetailViewCanvas_' + MultiWinId).setLayer(pinName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
$('#aaDetailViewCanvas_' + MultiWinId).setLayer(pinArcName, {
visible: false // set to true instead to show the layer again
}).drawLayers();
}
}
}
}
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
// remove event listener
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
$scope.removeOnDrawingCanvas(canvasElement);
}
}
}
}
$rootScope.switchToTransparencycanvas = function (paneld) {
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == undefined) return;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
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 = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
var TransCanvasZindex = ctx.style.zIndex;
var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex);
MaxZindexVal = MaxZindexVal + 1;
$("#" + canvasId).css("z-index", MaxZindexVal);
$(".ui-wrapper").css("z-index", MaxZindexVal + 1);
$('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal);
}
else {
var drawCanvasZindex = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).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")) {
$("#" + canvasPaintId).css("z-index", MaxZindexVal);
}
else {
$("#" + canvasId).css("z-index", MaxZindexVal);
$(".ui-wrapper").css("z-index", MaxZindexVal);
$('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal);
}
}
}
else {
var drawCanvasZindex = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
drawCanvasZindex = parseInt(drawCanvasZindex) + 1;
paintCanvasZindex = parseInt(paintCanvasZindex) + 1;
if (drawCanvasZindex > paintCanvasZindex) {
$(".ui-wrapper").css("z-index", drawCanvasZindex);
$("#" + canvasId).css("z-index", drawCanvasZindex);
$rootScope.UIWrapperZIndex = drawCanvasZindex;
}
else {
$(".ui-wrapper").css("z-index", paintCanvasZindex);
$("#" + canvasId).css("z-index", paintCanvasZindex);
$rootScope.UIWrapperZIndex = paintCanvasZindex;
}
}
}
}
}
else {
var drawCanvasZindex = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
drawCanvasZindex = parseInt(drawCanvasZindex) + 1;
paintCanvasZindex = parseInt(paintCanvasZindex) + 1;
if (drawCanvasZindex > paintCanvasZindex) {
$(".ui-wrapper").css("z-index", drawCanvasZindex);
$("#" + canvasId).css("z-index", drawCanvasZindex);
$rootScope.UIWrapperZIndex = drawCanvasZindex;
}
else {
$(".ui-wrapper").css("z-index", paintCanvasZindex);
$("#" + canvasId).css("z-index", paintCanvasZindex);
$rootScope.UIWrapperZIndex = paintCanvasZindex;
}
}
}
$rootScope.DrawingMode = function () {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
//Annotation History
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
$("#OnIdentify").removeClass("annotationtoolbartab");
$("#DrawMode").addClass("annotationtoolbartab");
$('.btnCursor').addClass('activebtncolor');
$("#annotationpaintbrushsize").removeClass("activebtncolor");
$("#annotationpainteraser").removeClass("activebtncolor");
$rootScope.isEraseToolSelected = false;
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
$rootScope.switchCanvas(paneld);
if(paneld.match("AAImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var canvasId="#canvasAA_" + MultiWinId;
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
var aaPinDataArray=$rootScope.GetAAwindowData(MultiWinId,'aaPinData');
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == canvasId) {
for (var j = 0; j <= aaPinDataArray.length - 1; j++) {
if (($rootScope.jcanvasObjectArray[i].x <= parseInt(aaPinDataArray[j]._HeadX) && $rootScope.jcanvasObjectArray[i].y <= parseInt(aaPinDataArray[j]._HeadY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt(aaPinDataArray[j]._HeadX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt(aaPinDataArray[j]._HeadY)) || ($rootScope.jcanvasObjectArray[i].x <= parseInt(aaPinDataArray[j]._PinX) && $rootScope.jcanvasObjectArray[i].y <= parseInt(aaPinDataArray[j]._PinY)) && (($rootScope.jcanvasObjectArray[i].x + $rootScope.jcanvasObjectArray[i].width) >= parseInt(aaPinDataArray[j]._PinX) && ($rootScope.jcanvasObjectArray[i].y + $rootScope.jcanvasObjectArray[i].height) >= parseInt(aaPinDataArray[j]._PinY))) {
var pinName = 'Pin_' + aaPinDataArray[j]._PinId;
var pinArcName = 'PinArc_' + aaPinDataArray[j]._PinId;
$('#aaDetailViewCanvas_' + MultiWinId).setLayer(pinName, {
visible: true // set to true instead to show the layer again
}).drawLayers();
$('#aaDetailViewCanvas_' + MultiWinId).setLayer(pinArcName, {
visible: true // set to true instead to show the layer again
}).drawLayers();
}
}
}
}
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
// remove event listener
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
$scope.removeOnDrawingCanvas(canvasElement);
}
}
}
}
// Dissectible Anatomy > Settings should be disable if Annotation is Open.
$rootScope.ShowSettingWindow = function () {
if ($("#annotationTollbar").css("display") == "block") {
$('#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) {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-line").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.setListManagerZindex = true;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.shapeType = "Line";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if(paneld.match("AAImagePanel"))
{
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
}
$rootScope.switchToAnnotationCanvas = function (paneld,MultiWinId) {
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) return;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
var aaViewCanvasZIndex = $('#aaDetailViewCanvas_' + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#" + canvasPaintId).css("z-index");
if (parseInt(aaViewCanvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$("#" + canvasId).css("z-index", canvasPaintZIndex);
}
else {
aaViewCanvasZIndex = parseInt(aaViewCanvasZIndex) + 1;
$("#" + canvasId).css("z-index", aaViewCanvasZIndex);
}
}
$rootScope.DrawPin = function (e) {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-pin").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.setListManagerZindex = true;
$rootScope.shapeType = "Pin";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if (paneld.match("AAImagePanel")) {
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
}
$rootScope.Cursor = function () {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$rootScope.shapeType = "cursor";
$(".btn-annotation").removeClass("activebtncolor");
// $("#" + e.currentTarget.id).removeClass("activebtncolor");
$('.btnCursor').addClass('activebtncolor');
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
//get only AAmodule
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
$rootScope.switchCanvas(paneld);
if(paneld.match("AAImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
// remove event listener
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
$scope.removeOnDrawingCanvas(canvasElement);
}
}
}
}
$rootScope.DrawRectangle = function (e) {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-rectangle").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.setListManagerZindex = true;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.shapeType = "Rectangle";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if(paneld.match("AAImagePanel"))
{
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
$rootScope.paintBrush = function () {
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-brush").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if ($rootScope.disableAnnotationtoolOnListManager == true) {
$rootScope.switchCanvas(paneld);
var canvasPaintZindex = $("#" + canvasPaintId).css("z-index"); //x
var canvasZindex = $("#" + canvasId).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;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
if ((document.getElementById('fill-option').checked == false) && ($rootScope.isShapeSyleOkBtnClicked == true)) {
$rootScope.switchCanvas(paneld);
}
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(paneld);
}
else {
$rootScope.switchCanvasToPaintCanvas(paneld);
}
$rootScope.shapeType = "FreeStylePaint";
$("#annotationpaintbrushsize").attr("data-size", parseInt($("#btnBrushSize").val()));
$("#annotationpaintbrushsize").attr("data-color", $rootScope.shapestyleColorWithOpacity);
if (parseInt($("#btnBrushSize").val()) <1) {
$("#" + canvasPaintId).sketch({ defaultSize: 1});
}
else {
$("#" + canvasPaintId).sketch();
}
$scope.PaintEraseEvent();
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
// remove event listener
$scope.removeOnDrawingCanvas(canvasElement);
}
}
}
$rootScope.EraseDrawing = function () {
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-erase").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasElement;
var canvasPaintId = canvasPaintElement.id;
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
$rootScope.switchCanvasToPaintCanvas(paneld);
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$('#' + canvasPaintId).sketch();
$("#annotationpainteraser").attr("data-size", parseInt($("#btnBrushSize").val()));
$scope.PaintEraseEvent();
// remove event listener
$scope.removeOnDrawingCanvas(canvasElement);
}
}
}
}
$scope.PaintEraseEvent=function()
{
$.sketch.tools.marker = {
onEvent: function(e) {
switch (e.type) {
case 'mousedown':
case 'touchstart':
if (this.painting) {
this.stopPainting();
}
this.color= $rootScope.shapestyleColorWithOpacity!=undefined ? $rootScope.shapestyleColorWithOpacity : "#fff";
this.size= parseInt($("#btnBrushSize").val());
if ($("#annotationpaintbrushsize").hasClass("activebtncolor")) {
this.tool='marker';
this.startPainting();
}
else if ($("#annotationpainteraser").hasClass("activebtncolor")) {
this.tool='eraser';
this.size=parseInt($("#btnBrushSize").val())>5?parseInt($("#btnBrushSize").val()):5;
this.startPainting();
}
else
{
this.stopPainting();
}
break;
case 'mouseup':
$rootScope.UnsaveCurriculum = true;
$scope.savePaintAnnotation(this.el.id,this.actions);
this.stopPainting();
break;
case 'touchend':
$rootScope.UnsaveCurriculum = true;
$scope.savePaintAnnotation(this.el.id,this.actions);
break;
case 'mouseout':
case 'mouseleave':
case 'touchcancel':
this.stopPainting();
}
if (this.painting) {
this.action.events.push({
x: e.pageX - this.canvas.offset().left,
y: e.pageY - this.canvas.offset().top,
event: e.type
});
return this.redraw();
}
},
draw: function(action) {
var event, previous, _i, _len, _ref;
this.context.lineJoin = "round";
this.context.lineCap = "round";
this.context.beginPath();
this.context.moveTo(action.events[0].x, action.events[0].y);
_ref = action.events;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
event = _ref[_i];
this.context.lineTo(event.x, event.y);
previous = event;
}
this.context.strokeStyle = action.color;
this.context.lineWidth = action.size;
return this.context.stroke();
}
};
$.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.switchCanvasToPaintCanvas = function (paneld) {
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null) return;
var canvasPaintElement =PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
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 = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
var TransCanvasZindex = ctx.style.zIndex;
var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex);
MaxZindexVal = MaxZindexVal + 1;
if (($("#" + canvasPaintId).css("display") == "block") && ($("#" + canvasId).css("display") == "block")) {
if ($("#OnIdentify").hasClass("annotationtoolbartab")) {
$("#" + canvasId).css("z-index", MaxZindexVal);
$('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal);
}
else {
if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) {
$("#" + canvasPaintId).css("z-index", MaxZindexVal);
}
else {
$("#" + canvasId).css("z-index", MaxZindexVal);
}
}
}
}
else {
var drawCanvasZindex = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex);
MaxZindexVal = parseInt(MaxZindexVal + 1);
if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) {
$("#" + canvasPaintId).css("z-index", MaxZindexVal);
}
else {
$("#" + canvasId).css("z-index", MaxZindexVal);
}
}
}
}
}
else {
var canvasPaint_zIndex = $("#" + canvasPaintId).css("z-index");
var canvas_zIndex = $("#" + canvasId).css("z-index");
if (canvas_zIndex > canvasPaint_zIndex) {
canvasPaint_zIndex = parseInt(canvas_zIndex) + 2;
}
else {
canvasPaint_zIndex = parseInt(canvasPaint_zIndex) + 2;
}
$("#" + canvasPaintId).css("z-index", canvasPaint_zIndex);
}
}
$rootScope.DrawCircle = function (e) {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-circle").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.setListManagerZindex = true;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.shapeType = "Circle";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if(paneld.match("AAImagePanel"))
{
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
}
$rootScope.DrawArrow = function (e) {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-arrow").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.setListManagerZindex = true;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.shapeType = "Arrow";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if(paneld.match("AAImagePanel"))
{
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
}
$rootScope.DrawText = function () {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$('.btnCursor').removeClass('activebtncolor');
$(".btn-annotation").removeClass("activebtncolor");
$(".btn-annotation-Text").addClass("activebtncolor");
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.setListManagerZindex = true;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.shapeType = "TextArea";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if(paneld.match("AAImagePanel"))
{
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
}
$rootScope.DrawPolygon = function () {
//clear sketch js event for paint and erase
$.sketch = { tools: {}};
$("#OnIdentify").removeClass('annotationtoolbartab');
$("#DrawMode").addClass('annotationtoolbartab');
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasPaintElement = PanelElement.canvasPaintElement;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
$rootScope.setListManagerZindex = true;
$("#" + canvasPaintId).css("display", "block");
$("#" + canvasId).css("display", "block");
$rootScope.switchCanvas(paneld);
$rootScope.shapeType = "DrawPolygon";
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
if(paneld.match("AAImagePanel"))
{
$rootScope.switchToAnnotationCanvas(paneld,MultiWinId);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
$scope.onDrawingCanvasOnModule(canvasElement);
}
}
}
}
$rootScope.switchCanvas = function (paneld) {
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
var canvasPaintElement = PanelElement.canvasPaintElement;
if (canvasElement == null) return;
var canvasId = canvasElement.id;
var canvasPaintId = canvasPaintElement.id;
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 = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
var TransCanvasZindex = ctx.style.zIndex;
var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex, TransCanvasZindex);
MaxZindexVal = MaxZindexVal + 1;
if ($("#OnIdentify").hasClass("annotationtoolbartab")) {
$("#" + canvasId).css("z-index", MaxZindexVal);
$('#' + ctx.getAttribute("id")).css("z-index", MaxZindexVal);
}
else {
if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) {
$("#" + canvasPaintId).css("z-index", MaxZindexVal + 1);
}
else
{
$("#" + canvasId).css("z-index", MaxZindexVal + 1);
}
}
}
else {
var drawCanvasZindex = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
var MaxZindexVal = Math.max(drawCanvasZindex, paintCanvasZindex);
MaxZindexVal = parseInt(MaxZindexVal + 1);
if ($("#annotationpaintbrushsize").hasClass("activebtncolor") || $("#annotationpainteraser").hasClass("activebtncolor")) {
$("#" + canvasPaintId).css("z-index", MaxZindexVal);
}
else {
$("#" + canvasId).css("z-index", MaxZindexVal);
}
}
}
}
}
else {
var drawCanvasZindex = $("#" + canvasId).css("z-index");
var paintCanvasZindex = $("#" + canvasPaintId).css("z-index");
if (drawCanvasZindex > paintCanvasZindex) {
paintCanvasZindex = parseInt(drawCanvasZindex) + 1;
} else {
paintCanvasZindex = parseInt(paintCanvasZindex) + 1;
}
$("#" + canvasId).css("z-index", paintCanvasZindex);
}
}
//birendra
//new method to get panel element
$scope.GetPanelElement = function (paneld) {
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement={};
if (paneld.match("daImagePanel")) {
PanelElement.canvasElement=document.getElementById('canvasDA_' + MultiWinId);
PanelElement.canvasPaintElement = document.getElementById('canvasPaintDA_' + MultiWinId);
PanelElement.canvasDivElement = document.getElementById('canvasDivDA_' + MultiWinId);
}
else if (paneld.match("AAImagePanel")) {
PanelElement.canvasElement=document.getElementById('canvasAA_' + MultiWinId);
PanelElement.canvasPaintElement = document.getElementById('canvasPaintAA_' + MultiWinId);
PanelElement.canvasDivElement = document.getElementById('canvasAADiv_' + MultiWinId);
}
else if (paneld.match("ciImagePanel")) {
PanelElement.canvasElement=document.getElementById('canvasCI_' + MultiWinId);
PanelElement.canvasPaintElement = document.getElementById('canvasPaintCI_' + MultiWinId);
PanelElement.canvasDivElement = document.getElementById('canvasDivCI_' + MultiWinId);
}
else if (paneld.match("aiImagePanel")) {
PanelElement.canvasElement=document.getElementById('canvasAI_' + MultiWinId);
PanelElement.canvasPaintElement = document.getElementById('canvasPaintAI_' + MultiWinId);
PanelElement.canvasDivElement = document.getElementById('canvasDivAI_' + MultiWinId);
}
else if (paneld.match("picImagePanel")) {
PanelElement.canvasElement=document.getElementById('canvasPIC_' + MultiWinId);
PanelElement.canvasPaintElement = document.getElementById('canvasPaintPIC_' + MultiWinId);
PanelElement.canvasDivElement = document.getElementById('canvasDivPIC_' + MultiWinId);
}
return PanelElement;
}
$rootScope.isShapeSyleOkBtnClicked = false;
$rootScope.setPropertiesForShapes = function (id) {
isfilloptionChecked = document.getElementById('fill-option').checked;
isOutlineOptionChecked = document.getElementById('Outline-Option').checked;
$rootScope.isShapeSyleOkBtnClicked = true;
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
if ($("#annotationpaintbrushsize").hasClass('activebtncolor')) {
$("#annotationpaintbrushsize").removeClass('activebtncolor')
$rootScope.switchCanvas(paneld);
}
if ($("#annotationpainteraser").hasClass('activebtncolor')) {
$("#annotationpainteraser").removeClass('activebtncolor')
$rootScope.switchCanvas(paneld);
}
if(paneld.match("ciImagePanel"))
{
var canvasZIndex = $("#canvasCI_" + MultiWinId).css("z-index");
var canvasPaintZIndex = $("#canvasPaintCI_" + MultiWinId).css("z-index");
if (parseInt(canvasZIndex) < parseInt(canvasPaintZIndex)) {
canvasPaintZIndex = parseInt(canvasPaintZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasPaintZIndex);
}
else {
canvasZIndex = parseInt(canvasZIndex) + 1;
$('#summary_' + MultiWinId).css("z-index", canvasZIndex);
}
}
}
}
}
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 = Math.round(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.changeWidthManager = function () {
var borderWidth = 2;
var borderColor = "#000";
borderWidth = $("#borderWidthCanvasElement option:selected").val();
$rootScope.shapestyleborderWidth = Math.round(borderWidth);
borderColor = $('#outlineColor .minicolors >.minicolors-swatch > .minicolors-swatch-color').css("background-color");
if (borderColor != null) {
document.getElementById("imgOpacity").parentNode.style.border = borderWidth + "px" + " " + "solid" + " " + borderColor;
//$("#imgOpacity").parent().css("border", borderWidth + "px" + " " + "solid" + borderColor);
} else {
// $("#imgOpacity").parent().css("border", borderWidth + "px" + " " + "solid");
document.getElementById("imgOpacity").parentNode.style.border = borderWidth + "px" + " " + "solid" + " " + borderColor;
}
}
$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";
$("#borderWidthCanvasElement").val($rootScope.shapestyleborderWidth).change();
$('#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) + "%");
};
}
$timeout(function(){
$('.btnCursor').trigger('click');
$(".btn-annotation").removeClass("activebtncolor");
$('.btnCursor').addClass('activebtncolor');
},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(2);
$('.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" });
}
$rootScope.LoadCBSavedAnnotation = function (canvasId,canvasPaintId,annotationData) {
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
if(paneld.match("daImagePanel"))
{
$rootScope.daAnnotationToolEvent(MultiWinId);
}
else if(paneld.match("AAImagePanel"))
{
$rootScope.aaAnnotationToolEvent(MultiWinId);
}
else if(paneld.match("ciImagePanel"))
{
$rootScope.ciAnnotationToolEvent(MultiWinId);
}
else if(paneld.match("aiImagePanel"))
{
$rootScope.aiAnnotationToolEvent(MultiWinId);
}
else if(paneld.match("picImagePanel"))
{
$rootScope.picAnnotationToolEvent(MultiWinId);
}
//for paint brush
$rootScope.switchCanvasToPaintCanvas(paneld);
}
}
}
$timeout(function () {
var shapeStates=annotationData.shapeStates;
var paintCanvasState=annotationData.paintCanvasState;
for(var shapeindx=0;shapeindx
0)
{
var drawingPoints=paintCanvasState
//auto save last cb paint
$scope.PaintEraseEvent();
$scope.savePaintAnnotation(canvasPaintId,drawingPoints);
$("#" + canvasPaintId).sketch({drawAction:drawingPoints});
}
$rootScope.CloseAnnotationTool();
}, 1000);
}
$scope.savePaintAnnotation=function(canvasPaintId,drawingPoints)
{
var len = (canvasPaintId).split("_").length;
var MultiWinId = (canvasPaintId).split("_")[len - 1];
//var modifiiedannotationData= {shapeStates:[],paintCanvasState:[]};
if (canvasPaintId.match("canvasPaintDA")) {
var annotationData=$rootScope.GetDAwindowData(MultiWinId,'annotationData');
annotationData.paintCanvasState=drawingPoints;
$rootScope.SetDAwindowData(MultiWinId,'annotationData',annotationData);
}
else if (canvasPaintId.match("canvasPaintAA")) {
var annotationData=$rootScope.GetAAwindowData(MultiWinId,'annotationData');
annotationData.paintCanvasState=drawingPoints;
$rootScope.SetAAwindowData(MultiWinId,'annotationData',annotationData);
}
else if (canvasPaintId.match("canvasPaintCI")) {
var annotationData=$rootScope.GetCIwindowData(MultiWinId,'annotationData');
annotationData.paintCanvasState=drawingPoints;
$rootScope.SetCIwindowData(MultiWinId,'annotationData',annotationData);
}
else if (canvasPaintId.match("canvasPaintAI")) {
var annotationData=$rootScope.GetAIwindowData(MultiWinId,'annotationData');
annotationData.paintCanvasState=drawingPoints;
$rootScope.SetAIwindowData(MultiWinId,'annotationData',annotationData);
}
else if (canvasPaintId.match("canvasPaintPIC")) {
var annotationData=$rootScope.GetPICwindowData(MultiWinId,'annotationData');
annotationData.paintCanvasState=drawingPoints;
$rootScope.SetPICwindowData(MultiWinId,'annotationData',annotationData);
}
}
//--Save Annotation activity in panel ------
$scope.SaveAnnotation=function(panelCanvasId,shapetype,layerName,drawingPoints)
{
var len = (panelCanvasId).split("_").length;
var MultiWinId = (panelCanvasId).split("_")[len - 1];
var modifiiedannotationData= {shapeStates:[],paintCanvasState:""};
if (panelCanvasId.match("canvasDA")) {
var annotationData=$rootScope.GetDAwindowData(MultiWinId,'annotationData');
modifiiedannotationData= $scope.UpdateShapeData(shapetype,layerName,drawingPoints,annotationData);
$rootScope.SetDAwindowData(MultiWinId,'annotationData',modifiiedannotationData);
}
else if (panelCanvasId.match("canvasAA")) {
var annotationData=$rootScope.GetAAwindowData(MultiWinId,'annotationData');
modifiiedannotationData= $scope.UpdateShapeData(shapetype,layerName,drawingPoints,annotationData);
$rootScope.SetAAwindowData(MultiWinId,'annotationData',modifiiedannotationData);
}
else if (panelCanvasId.match("canvasCI")) {
var annotationData=$rootScope.GetCIwindowData(MultiWinId,'annotationData');
modifiiedannotationData= $scope.UpdateShapeData(shapetype,layerName,drawingPoints,annotationData);
$rootScope.SetCIwindowData(MultiWinId,'annotationData',modifiiedannotationData);
}
else if (panelCanvasId.match("canvasAI")) {
var annotationData=$rootScope.GetAIwindowData(MultiWinId,'annotationData');
modifiiedannotationData= $scope.UpdateShapeData(shapetype,layerName,drawingPoints,annotationData);
$rootScope.SetAIwindowData(MultiWinId,'annotationData',modifiiedannotationData);
}
else if (panelCanvasId.match("canvasPIC")) {
var annotationData=$rootScope.GetPICwindowData(MultiWinId,'annotationData');
modifiiedannotationData= $scope.UpdateShapeData(shapetype,layerName,drawingPoints,annotationData);
$rootScope.SetPICwindowData(MultiWinId,'annotationData',modifiiedannotationData);
}
}
$scope.UpdateShapeData=function(shapetype,layerName,drawingPoints,annotationData)
{
var shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.where('layerName == ' + layerName)
.select();
if(shapeStates.length>0)
{
if(shapetype=="line"||shapetype=="Arrow"||shapetype=="Pin")
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.update(function (coll, index)
{
coll[index].x1= drawingPoints.x1;
coll[index].y1 = drawingPoints.y1;
coll[index].x2 = drawingPoints.x2;
coll[index].y2 = drawingPoints.y2;
coll[index].style = drawingPoints.style;
})
.at('layerName == ' + layerName)
.select();
}
else if(shapetype=="rectangle"||shapetype=="ellipse")
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.update(function (coll, index)
{
coll[index].x= drawingPoints.x;
coll[index].y = drawingPoints.y;
coll[index].size = drawingPoints.size;
coll[index].style = drawingPoints.style;
})
.at('layerName == ' + layerName)
.select();
}
else if(shapetype=="textArea")
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.update(function (coll, index)
{
coll[index].x= drawingPoints.x;
coll[index].y = drawingPoints.y;
coll[index].size = drawingPoints.size;
coll[index].text = drawingPoints.text;
coll[index].shapestyle = drawingPoints.shapestyle;
coll[index].textstyle = drawingPoints.textstyle;
})
.at('layerName == ' + layerName)
.select();
}
}
else
{
annotationData.shapeStates.push(drawingPoints);
}
return annotationData;
}
//--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({
panelCanvasId:canvasId,
name: 'Line_' + LineNumber,
layer: true,
type: 'line',
draggable: true,
strokeStyle: shapestyleborderColor,
strokeWidth: shapestyleborderWidth,
rounded: true,
x1: offsetX1, y1: offsetY1,
x2: x, y2: y,
add: function (layer) {
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1),
"y1": Math.round(layer.y1),
"x2": Math.round(layer.x2),
"y2": Math.round(layer.y2),
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
},
dragstop:function(layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for save aanotation data
// layer.draggable = false;
var move_x=Math.round(layer.x);
var move_y=Math.round(layer.y);
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1)+move_x,
"y1": Math.round(layer.y1)+move_y,
"x2": Math.round(layer.x2)+move_x,
"y2": Math.round(layer.y2)+move_y,
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
// "size": { height: 600, width: 900 }
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
}
},
handlestop:function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for resize line
layer.draggable = false;
var move_x=Math.round(layer.x);
var move_y=Math.round(layer.y);
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1)+move_x,
"y1": Math.round(layer.y1)+move_y,
"x2": Math.round(layer.x2)+move_x,
"y2": Math.round(layer.y2)+move_y,
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
//remove arc
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 0,
radius: 0
}
}).drawLayers();
}
},
mouseout: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).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;
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name});
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: layer.strokeWidth<=3?3:layer.strokeWidth-1,
radius: layer.strokeWidth<=3?3:layer.strokeWidth-1,
}
}).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, width, height) {
if ($rootScope.isRectanglePreviewCompleted == true) {
if(width<30) width=30 ;
if(height<30) height=30;
$rootScope.isRectanglePreviewCompleted = false;
$("#"+canvasId).addLayer({
panelCanvasId:canvasId,
layer: true,
name: 'Rect_' + RectNumber,
fillStyle: shapestyleFillColor,
type: 'rectangle',
draggable: true,
strokeStyle: shapestyleborderColor,
opacity: shapestyleOpacity,
strokeWidth: shapestyleborderWidth,
fromCenter: false,
x: offsetX1, y: offsetY1,
width: width,
height: height,
minWidth:30,
minHeight:30,
resizeFromCenter: false,
add: function (layer) {
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle,opacity:layer.opacity,fillStyle:layer.fillStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
if ((layer.panelCanvasId).match("canvasAA")) {
$rootScope.jcanvasObjectArray.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
if ((layer.panelCanvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == layer.panelCanvasId) {
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;
}
}
}
}
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle,opacity:layer.opacity,fillStyle:layer.fillStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
}
},
handlestop:function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for resize line
layer.draggable = false;
if ((layer.panelCanvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == layer.panelCanvasId) {
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;
}
}
}
}
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle,opacity:layer.opacity,fillStyle:layer.fillStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'rectangle',
fillStyle: 'pink',
strokeStyle: 'yellow',
strokeWidth: 0,
width: 0, height: 0,
cornerRadius: 0,
}
}).drawLayers();
}
},
mouseout: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).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;
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name});
$("#"+layer.panelCanvasId).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, width, height) {
if ($rootScope.isCirclePreviewCompleted == true) {
if(width<30) width=30 ;
if(height<30) height=30;
$rootScope.isCirclePreviewCompleted = false;
$("#"+canvasId).addLayer({
panelCanvasId:canvasId,
layer: true,
name: 'Circle_' + CircleNumber,
type: 'ellipse',
opacity: shapestyleOpacity,
draggable: true,
strokeStyle: shapestyleborderColor,
strokeWidth: shapestyleborderWidth,
fillStyle: shapestyleFillColor,
fromCenter: false,
x: offsetX1,
y: offsetY1,
width: width,
height: height,
minWidth:30,
minHeight:30,
// Place a handle at each side and each corner
resizeFromCenter: false,
handlePlacement: 'both',
add: function (layer) {
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle,opacity:layer.opacity,fillStyle:layer.fillStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
if ((layer.panelCanvasId).match("canvasAA")) {
$rootScope.jcanvasObjectArray.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
if ((layer.panelCanvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == layer.panelCanvasId) {
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;
}
}
}
}
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle,opacity:layer.opacity,fillStyle:layer.fillStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
}
},
handlestop:function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for resize line
layer.draggable = false;
if ((layer.panelCanvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == layer.panelCanvasId) {
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;
}
}
}
}
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle,opacity:layer.opacity,fillStyle:layer.fillStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 0,
radius: 0
}
}).drawLayers();
}
},
mouseout: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 0,
radius: 0
}
}).drawLayers();
}
else {
layer.draggable = false;
}
},
mouseover: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name});
$("#"+layer.panelCanvasId).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.DrawArrowOnModuleItem = function (canvasId, ArrowNumber, shapestyleborderColor, shapestyleborderWidth, offsetX1, offsetY1, x, y) {
if ($rootScope.isArrowPreviewCompleted == true) {
$rootScope.isArrowPreviewCompleted = false;
$("#"+canvasId).drawLine({
panelCanvasId:canvasId,
layer: true,
type:'Arrow',
name: 'Arrow_' + ArrowNumber,
draggable: true,
strokeStyle: shapestyleborderColor,
strokeWidth: shapestyleborderWidth,
rounded: true,
endArrow: true,
arrowRadius: 7,
arrowAngle: 90,
x1: offsetX1, y1: offsetY1,
x2: x, y2: y,
add: function (layer) {
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1),
"y1": Math.round(layer.y1),
"x2": Math.round(layer.x2),
"y2": Math.round(layer.y2),
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
},
dragstop:function(layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for save aanotation data
//layer.draggable = false;
var move_x=Math.round(layer.x);
var move_y=Math.round(layer.y);
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1)+move_x,
"y1": Math.round(layer.y1)+move_y,
"x2": Math.round(layer.x2)+move_x,
"y2": Math.round(layer.y2)+move_y,
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
}
},
handlestop:function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for resize line
layer.draggable = false;
var move_x=Math.round(layer.x);
var move_y=Math.round(layer.y);
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1)+move_x,
"y1": Math.round(layer.y1)+move_y,
"x2": Math.round(layer.x2)+move_x,
"y2": Math.round(layer.y2)+move_y,
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
//remove arc
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 0,
radius: 0
}
}).drawLayers();
}
},
mouseout: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).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;
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name});
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: layer.strokeWidth<=3?3:layer.strokeWidth-1,
radius: layer.strokeWidth<=3?3:layer.strokeWidth-1,
}
}).drawLayers();
}
else {
//jcanvas property
layer.draggable = false;
}
}
});
}
$('.btnCursor').trigger('click');
$(".btn-annotation").removeClass("activebtncolor");
$('.btnCursor').addClass('activebtncolor');
}
$rootScope.DrawPinOnModuleItem = function (canvasId, PinNumber,shapestyleborderColor, shapestyleborderWidth, offsetX1, offsetY1, x, y) {
if ($rootScope.isPinPreviewCompleted == true) {
$rootScope.isPinPreviewCompleted = false;
var radial = $("#"+canvasId).createGradient({
x1: 50, y1: 50,
x2: 50, y2: 50,
r1: 10, r2: 30,
c1: 'rgba(100, 50, 0,0)',
c2: 'grey'
});
$("#"+canvasId).drawLine({
panelCanvasId:canvasId,
draggable: true,
layer: true,
type:'Pin',
name: "Pin_" + PinNumber,
groups: ["Pin_" + PinNumber],
dragGroups: ["Pin_" + PinNumber],
strokeStyle: 'black',
strokeWidth: shapestyleborderWidth,
x1: offsetX1, y1: offsetY1,
x2: x, y2: y,
add: function (layer) {
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1),
"y1": Math.round(layer.y1),
"x2": Math.round(layer.x2),
"y2": Math.round(layer.y2),
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
},
dragstop:function(layer)
{
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for save aanotation data
//layer.draggable = false;
var move_x=Math.round(layer.x);
var move_y=Math.round(layer.y);
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1)+move_x,
"y1": Math.round(layer.y1)+move_y,
"x2": Math.round(layer.x2)+move_x,
"y2": Math.round(layer.y2)+move_y,
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
}
},
handlestop:function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//add new event for resize line
layer.draggable = false;
var move_x=Math.round(layer.x);
var move_y=Math.round(layer.y);
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x1": Math.round(layer.x1)+move_x,
"y1": Math.round(layer.y1)+move_y,
"x2": Math.round(layer.x2)+move_x,
"y2": Math.round(layer.y2)+move_y,
"style":{thickness:layer.strokeWidth,color:layer.strokeStyle}
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
//remove arc
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: 0,
radius: 0
}
}).drawLayers();
}
},
mouseout: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.shapeTypePin = "";
$rootScope.canvasLayerNameCollection = [];
$("#"+layer.panelCanvasId).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;
$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({"panelCanvasId":layer.panelCanvasId, pinName: layer.name, ArcName: pinResult });
$("#"+layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'arc',
fillStyle: '#fff',
strokeStyle: '#c33',
strokeWidth: layer.strokeWidth<=3?3:layer.strokeWidth-1,
radius: layer.strokeWidth<=3?3:layer.strokeWidth-1,
}
}).drawLayers();
}
else {
//jcanvas property
layer.draggable = false;
}
}
}).drawArc({
draggable: true,
panelCanvasId:canvasId,
name: "ArcPin_" + PinNumber,
layer: true,
groups: ["Pin_" + PinNumber],
dragGroups: ["Pin_" + PinNumber],
strokeStyle: 'grey',
strokeWidth: shapestyleborderWidth,
fillStyle: radial,
x: x, y: y,
radius: 5,
add: function (layer) {
layer.draggable = false;
},
}).drawLayers();
}
$('.btnCursor').trigger('click');
$(".btn-annotation").removeClass("activebtncolor");
$('.btnCursor').addClass('activebtncolor');
}
$rootScope.textWidth = [];
var isDoubleTouchSaveText = null;
$rootScope.TextEditorFunctionality = function (canvasId, TextNumber,stringText, shapestyle,textstyle, offsetX1, offsetY1,width, height) {
if ($rootScope.isTextAreaPreviewCompleted == true) {
$rootScope.isTextAreaPreviewCompleted = false;
$scope.emptydraw=true;
$scope.selectedCanvasId=canvasId;
$scope.selectedTextRect="TextRect_" + TextNumber;
$scope.selectedTextArea='TextArea_' + TextNumber;
var newGroupName='TextRectArea_' + TextNumber;
$rootScope.rectDimension.push({panelCanvasId:canvasId,name: $scope.selectedTextRect, groupName:newGroupName, width: width, height: height, x: offsetX1, y: offsetY1,shapestyle:shapestyle });
if(textstyle=="")
{
// add empty text style
textstyle={fontSize:"",fontWeight:"",fontStyle:"",textAlignmt:"",fontColor:"", fontFamily:""};
$rootScope.textDimension.push({panelCanvasId:canvasId,name: $scope.selectedTextArea, stringText:stringText,textstyle:textstyle});
// Annotation: Edit Text option is missing.
$("#annotationTextModal").css("padding-right", "0px");
$("#annotationTextModal").modal("toggle");
document.getElementById('modelbackground').style.display = "block";
$scope.resetTextarea(shapestyle.fillStyle);
}
else
{
$rootScope.textDimension.push({panelCanvasId:canvasId,name: $scope.selectedTextArea, stringText:stringText,textstyle:textstyle});
$rootScope.TextEditorDrawText($scope.selectedCanvasId,$scope.selectedTextRect,$scope.selectedTextArea);
}
}
}
$scope.resetTextarea=function(shapefillcolor)
{
$('.btnCursor').trigger('click');
$("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" });
$("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color', shapefillcolor);
$("#text_area").css("color", "#000000");
$("#text_area").css("background-color", shapefillcolor);
$("#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-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');
}
$scope.GetTextEditorStyle=function(canvasId,selectedTextRect,selectedTextArea)
{
// getting textarea style properties
$rootScope.rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.update(function (coll, index) {
coll[index].shapestyle.fillStyle = $("#text_area").css("background-color");
})
.at('panelCanvasId == ' + canvasId,'name == ' + selectedTextRect)
.select();
$rootScope.textDimension = new jinqJs()
.from($rootScope.textDimension)
.update(function (coll, index)
{
coll[index].textstyle.textAlignmt = $("#text_area").css("text-align");
coll[index].textstyle.fontColor = $("#text_area").css("color");
coll[index].textstyle.fontSize = $("#text_area").css("font-size");
coll[index].textstyle.fontWeight = $("#text_area").css("font-weight");
coll[index].textstyle.fontStyle = $("#text_area").css("font-style");
coll[index].textstyle.fontFamily = $("#text_area").css("font-family");
})
.at('panelCanvasId == ' + canvasId,'name == ' + selectedTextArea)
.select();
}
$rootScope.saveText = function () {
$rootScope.IsTextAlreadySave = false;
$scope.emptydraw=false;
var canvasId = $scope.selectedCanvasId ;
if (canvasId == null) return;
var selectedTextRect = $scope.selectedTextRect;
var selectedTextArea = $scope.selectedTextArea;
$scope.GetTextEditorStyle(canvasId,selectedTextRect,selectedTextArea);
var areaText = $("#text_area").val();
$rootScope.TextEditorDrawText(canvasId,selectedTextRect,selectedTextArea,areaText);
}
$rootScope.closeModal = function () {
if( $scope.emptydraw==true)
{
var canvasId = $scope.selectedCanvasId ;
if (canvasId == null) return;
var selectedTextRect = $scope.selectedTextRect;
var selectedTextArea = $scope.selectedTextArea;
$("#text_area").val('');
var areaText = $("#text_area").val();
$("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color', "rgb(255, 255, 255)");
$("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": "#000000" });
$("#text_area").css("color", "#000000");
$("#text_area").css("background-color", "rgb(255, 255, 255)");
$scope.GetTextEditorStyle(canvasId,selectedTextRect,selectedTextArea);
$rootScope.TextEditorDrawText(canvasId,selectedTextRect,selectedTextArea,areaText);
}
document.getElementById('modelbackground').style.display = "none";
}
$scope.UpdateTextEditor=function(TextPropertyArray,fillStyle)
{
if (TextPropertyArray.length>0) {
var TextEditorstyle=TextPropertyArray[0].textstyle;
var textArrVal = TextPropertyArray[0].stringText;
// this line of code replace the line breaks and convert into a single line.
textArrVal = textArrVal.replace(/(\n)/gm, "");
$("#text_area").val(textArrVal);
$("#drawTextBGColorpicker span.minicolors-swatch-color").css('background-color', fillStyle);
$("#text_area").css("background-color", fillStyle);
$("#text_area").css("font-size", TextEditorstyle.fontSize);
$("#text_area").css("font-weight", TextEditorstyle.fontWeight);
$("#text_area").css("font-style", TextEditorstyle.fontStyle);
$("#text_area").css("text-align", TextEditorstyle.textAlignmt);
$("#text_area").css("color", TextEditorstyle.fontColor);
$("#text_area").css("font-family", TextEditorstyle.fontFamily);
//$("#text_area").css("text-decoration", TextEditorstyle.TextDecoration);
$("#font-color .minicolors .minicolors-swatch .minicolors-swatch-color").css({ "background-color": TextEditorstyle.fontColor });
var CurrentFontFamily = TextEditorstyle.fontFamily;
var CurrentFontSize = parseInt(CurrentFontFamily.fontSize);
$("#selected-font-family option[value=" + CurrentFontFamily + "]").prop('selected', true);
$("#selected-font-size option[value=" + CurrentFontSize + "]").prop('selected', true);
//adding text font weight active class in text edit pop-up
if (TextEditorstyle.fontWeight == 700) {
$("#text-bold").addClass("ActiveFormattingButtonClass");
}
else {
$("#text-bold").removeClass("ActiveFormattingButtonClass");
}
//adding text font style active class in text edit pop-up
if (TextEditorstyle.fontStyle == "italic") {
$("#text-italic").addClass("ActiveFormattingButtonClass");
}
else {
$("#text-italic").removeClass("ActiveFormattingButtonClass");
}
//adding text alignment active class in text edit pop-up
if (CurrentFontFamily.Align == "left") {
$("#text-right").removeClass("ActiveFormattingButtonClass");
$("#text-center").removeClass("ActiveFormattingButtonClass")
$("#text-left").addClass("ActiveFormattingButtonClass");
}
else if (CurrentFontFamily.Align == "right") {
$("#text-center").removeClass("ActiveFormattingButtonClass")
$("#text-left").removeClass("ActiveFormattingButtonClass");
$("#text-right").addClass("ActiveFormattingButtonClass");
}
else if (CurrentFontFamily.Align == "center") {
$("#text-left").removeClass("ActiveFormattingButtonClass");
$("#text-right").removeClass("ActiveFormattingButtonClass");
$("#text-center").addClass("ActiveFormattingButtonClass");
}
}
textArrVal = '';
$("#annotationTextModal").css("padding-right", "0px");
document.getElementById('modelbackground').style.display = "block";
$("#annotationTextModal").modal("toggle");
}
$rootScope.TextEditorDrawText=function(canvasId,selectedTextRect,selectedTextArea,areaText)
{
document.getElementById('modelbackground').style.display = "none";
// this part will work first time when save button will be clicked
if ($rootScope.IsTextAlreadySave == false) {
if(areaText!=undefined)
{
//not use while open from CB
$rootScope.textDimension = new jinqJs()
.from($rootScope.textDimension)
.update(function (coll, index) { coll[index].stringText = areaText; })
.at('panelCanvasId == ' + canvasId,'name == ' + selectedTextArea)
.select();
}
var rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.where('panelCanvasId == ' + canvasId,'name == ' + selectedTextRect)
.select();
var textDimension = new jinqJs()
.from($rootScope.textDimension)
.where('panelCanvasId == ' + canvasId,'name == ' + selectedTextArea)
.select();
// code for horizonatl text going out
// deleting previous text area
$("#" + canvasId).removeLayer(textDimension[0].name).drawLayers();// remove text
$("#" + canvasId).removeLayer(rectDimension[0].name).drawLayers();//remove rect
if ((canvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == canvasId) {
if ($rootScope.jcanvasObjectArray[i].name == $rootScope.initialTextAreaName) {
$rootScope.jcanvasObjectArray.splice(i, 1);
$rootScope.initialTextAreaName = '';
}
}
}
}
$("#" + canvasId).drawText({
panelCanvasId:canvasId,
layer: true,
name: 'temptext',//use for intially adjust height and width of text for rectangle
fillStyle:textDimension[0].textstyle.fontColor,
fontStyle: textDimension[0].textstyle.fontWeight + " " + textDimension[0].textstyle.fontStyle,
fontSize: textDimension[0].textstyle.fontSize,
fromCenter: false,
fontFamily: textDimension[0].textstyle.fontFamily,
align: textDimension[0].textstyle.textAlignmt,
strokeWidth: 0,
text: textDimension[0].stringText,
x: rectDimension[0].x, y: rectDimension[0].y,
maxWidth:rectDimension[0].width,
add: function (layer) {
// internal use
// use to calculate minwidth of rectangle by longest word with applied css
var str=layer.text;
var splittext=str.split(" ");
var longtext= longest_string(splittext)[0];
var test = document.getElementById("atTextDiv");
test.style.fontSize = layer.fontSize;
test.style.fontFamily = layer.fontFamily;
test.style.fontWeight = layer.fontStyle.split(" ")[0];
test.style.fontStyle = layer.fontStyle.split(" ")[1];
$('#atTextDiv').html(longtext);
},
}).drawRect({
panelCanvasId:canvasId,
name: rectDimension[0].name,
groups: [rectDimension[0].groupName],
dragGroups: [rectDimension[0].groupName],
layer: true,
draggable: true,
type:'textArea',
opacity: rectDimension[0].shapestyle.opacity,
strokeStyle: rectDimension[0].shapestyle.color,
strokeWidth: rectDimension[0].shapestyle.thickness,
fillStyle: rectDimension[0].shapestyle.fillStyle,
fromCenter: false,
x: rectDimension[0].x, y: rectDimension[0].y,
width: $("#" + canvasId).measureText('temptext').width>20?$("#" + canvasId).measureText('temptext').width+10:40,
height:$("#" + canvasId).measureText('temptext').height>20?$("#" + canvasId).measureText('temptext').height+10:40,
minWidth:document.getElementById("atTextDiv").clientWidth>20?document.getElementById("atTextDiv").clientWidth+10:40,
minHeight:$("#" + canvasId).measureText('temptext').height>20?$("#" + canvasId).measureText('temptext').height:40,
resizeFromCenter: false,
add: function (layer) {
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"text":textDimension[0].stringText,
"shapestyle":rectDimension[0].shapestyle,
"textstyle":textDimension[0].textstyle
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
if ((layer.panelCanvasId).match("canvasAA")) {
$rootScope.initialTextAreaName = layer.name;
$rootScope.jcanvasObjectArray.push({"panelCanvasId":layer.panelCanvasId, "name": layer.name, "x": layer.x, "y": layer.y, "width": layer.width, "height": layer.height });
}
},
dragstop: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var rectName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
var positionX=layer.x;
var positionY=layer.y;
$scope.dragstopEvent(layer.panelCanvasId,rectName,textareaName,positionX,positionY);
}
else {
//jcanvas property
layer.draggable = false;
}
},
dblclick: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var rectName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
$scope.dblclickEvent(layer.panelCanvasId,rectName,textareaName);
}
else {
//jcanvas property
layer.draggable = false;
}
},
touchstart: function (layer) {
if (isDoubleTouchSaveText == null) {
isDoubleTouchSaveText = setTimeout(function () {
isDoubleTouchSaveText = null;
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
$rootScope.shapeTypeText = "textAreaRect";
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
var concatinateResult = textareaName;// text area name
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push({panelCanvasId:layer.panelCanvasId, textareaRectangle: layer.name, textareaString: concatinateResult });
$("#" + layer.panelCanvasId).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;
}
}, 1000)
}
else
{
clearTimeout(isDoubleTouchSaveText);
isDoubleTouchSaveText = null;
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var rectName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
$scope.dblclickEvent(layer.panelCanvasId,rectName,textareaName);
}
else {
//jcanvas property
layer.draggable = false;
}
}
},
mouseout: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = false;
$rootScope.canvasLayerNameCollection = [];
$("#" + layer.panelCanvasId).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;
$rootScope.shapeTypeText = "textAreaRect";
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
var concatinateResult = textareaName;// text area name
$rootScope.canvasLayerNameCollection = [];
$rootScope.canvasLayerNameCollection.push({panelCanvasId:layer.panelCanvasId, textareaRectangle: layer.name, textareaString: concatinateResult });
$("#" + layer.panelCanvasId).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;
}
},
handlemove: function(layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
// change min height of reactangle
var textheight=$("#" + layer.panelCanvasId).measureText(textareaName).height+10;
layer.minHeight= textheight;
$("#" + layer.panelCanvasId).removeLayer(textareaName).drawLayers();
var textDimension = new jinqJs()
.from($rootScope.textDimension)
.where('panelCanvasId == ' + layer.panelCanvasId,'name == ' + textareaName)
.select();
$("#" + layer.panelCanvasId).drawText({
panelCanvasId:layer.panelCanvasId,
layer: true,
draggable: true,
name: textareaName,
groups: [layer.groups],
dragGroups: [layer.dragGroups],
fillStyle:textDimension[0].textstyle.fontColor,
fontStyle:textDimension[0].textstyle.fontWeight + " " + textDimension[0].textstyle.fontStyle,
fontSize: textDimension[0].textstyle.fontSize,
fromCenter: false,
fontFamily: textDimension[0].textstyle.fontFamily,
align: textDimension[0].textstyle.textAlignmt,
strokeWidth: 0,
text: textDimension[0].stringText,
x: layer.x+5, y: layer.y+5,
maxWidth:layer.width-2,
add: function (layer) {
layer.draggable = true;
},
dragstop: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var textareaName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var rectName="TextRect_" +txtnumber;
var positionX=layer.x;
var positionY=layer.y;
$scope.dragstopEvent(layer.panelCanvasId,rectName,textareaName,positionX,positionY);
}
else {
//jcanvas property
layer.draggable = false;
}
},
dblclick: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var textareaName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var rectName="TextRect_" +txtnumber;
$scope.dblclickEvent(layer.panelCanvasId,rectName,textareaName);
}
else {
//jcanvas property
layer.draggable = false;
}
},
mouseover: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
}
else {
//jcanvas property
layer.draggable = false;
}
}
});
}
},
handlestop:function (layer) {
//add new event for resize line
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
layer.draggable = false;
if ((layer.panelCanvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == layer.panelCanvasId) {
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;
}
}
}
}
var txtnumber=(layer.name).split('_')[1];
var textareaName="TextArea_" +txtnumber;
$rootScope.rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.update(function (coll, index) {
coll[index].height = layer.height;
coll[index].width = layer.width;
})
.at('panelCanvasId == ' + layer.panelCanvasId,'name == ' + layer.name)
.select();
var rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.where('panelCanvasId == ' + layer.panelCanvasId,'name == ' + layer.name)
.select();
var textDimension = new jinqJs()
.from($rootScope.textDimension)
.where('panelCanvasId == ' + layer.panelCanvasId,'name == ' + textareaName)
.select();
var drawingPoints={
"layerName": layer.name,//for internal use
"shapeType":layer.type,
"x": Math.round(layer.x),
"y": Math.round(layer.y),
"size": {width:layer.width,height:layer.height},
"text":textDimension[0].stringText,
"shapestyle":rectDimension[0].shapestyle,
"textstyle":textDimension[0].textstyle
}
$scope.SaveAnnotation(layer.panelCanvasId,layer.type,layer.name,drawingPoints);
$rootScope.canvasLayerNameCollection = [];
$("#" + layer.panelCanvasId).setLayer(layer.name, {
handle: {
type: 'rectangle',
fillStyle: 'pink',
strokeStyle: 'yellow',
strokeWidth: 0,
width: 0, height: 0,
cornerRadius: 0
}
}).drawLayers();
}
}
}).drawText({
panelCanvasId:canvasId,
layer: true,
draggable: true,
name: textDimension[0].name,
groups: [rectDimension[0].groupName],
dragGroups: [rectDimension[0].groupName],
fillStyle:textDimension[0].textstyle.fontColor,
fontStyle: textDimension[0].textstyle.fontWeight + " " + textDimension[0].textstyle.fontStyle,
fontSize: textDimension[0].textstyle.fontSize,
fromCenter: false,
fontFamily: textDimension[0].textstyle.fontFamily,
align: textDimension[0].textstyle.textAlignmt,
strokeWidth: 0,
text: textDimension[0].stringText,
x: rectDimension[0].x+5, y: rectDimension[0].y+5,
maxWidth:rectDimension[0].width,
add: function (layer) {
layer.draggable = true;
//remove temptext
$("#" + canvasId).removeLayer('temptext').drawLayers();
},
dragstop: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var textareaName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var rectName="TextRect_" +txtnumber;
var positionX=layer.x;
var positionY=layer.y;
$scope.dragstopEvent(layer.panelCanvasId,rectName,textareaName,positionX,positionY);
}
else {
//jcanvas property
layer.draggable = false;
}
},
dblclick: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
var textareaName=layer.name;
var txtnumber=(layer.name).split('_')[1];
var rectName="TextRect_" +txtnumber;
$scope.dblclickEvent(layer.panelCanvasId,rectName,textareaName);
}
else {
//jcanvas property
layer.draggable = false;
}
},
mouseover: function (layer) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == true) {
//jcanvas property
layer.draggable = true;
}
else {
//jcanvas property
layer.draggable = false;
}
}
});
}
}
function longest_string(str_ara) {
let max = str_ara[0].length;
str_ara.map(v => max = Math.max(max, v.length));
var result = str_ara.filter(v => v.length == max);
return result;
}
$scope.dragstopEvent=function(panelCanvasId,rectName,textareaName,positionX,positionY)
{
if ((panelCanvasId).match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if ($rootScope.jcanvasObjectArray[i].panelCanvasId == panelCanvasId) {
if ($rootScope.jcanvasObjectArray[i].name == rectName) {
$rootScope.jcanvasObjectArray[i].x = positionX;
$rootScope.jcanvasObjectArray[i].y = positionY;
}
}
}
}
$rootScope.rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.update(function (coll, index) {
coll[index].x = Math.round(positionX);
coll[index].y = Math.round(positionY);
})
.at('panelCanvasId == ' + panelCanvasId,'name == ' + rectName)
.select();
var rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.where('panelCanvasId == ' + panelCanvasId,'name == ' + rectName)
.select();
var textDimension = new jinqJs()
.from($rootScope.textDimension)
.where('panelCanvasId == ' + panelCanvasId,'name == ' + textareaName)
.select();
var drawingPoints={
"layerName": rectName,//for internal use
"shapeType":'textArea',
"x": Math.round(positionX),
"y": Math.round(positionY),
"size": {width:rectDimension[0].width,height:rectDimension[0].height},
"text":textDimension[0].stringText,
"shapestyle":rectDimension[0].shapestyle,
"textstyle":textDimension[0].textstyle
}
$scope.SaveAnnotation(panelCanvasId,'textArea',rectName,drawingPoints);
}
$scope.dblclickEvent=function(panelCanvasId,rectName,textareaName)
{
$rootScope.IsTextAlreadySave = true;
$scope.selectedCanvasId=panelCanvasId;
$scope.selectedTextRect=rectName;
$scope.selectedTextArea=textareaName;
var TextPropertyArray = new jinqJs()
.from($rootScope.textDimension)
.where('panelCanvasId == ' + panelCanvasId,'name == ' + textareaName)
.select();
var rectDimension = new jinqJs()
.from($rootScope.rectDimension)
.where('panelCanvasId == ' + panelCanvasId,'name == ' + rectName)
.select();
$scope.UpdateTextEditor(TextPropertyArray,rectDimension[0].shapestyle.fillStyle);
}
$rootScope.clicked = false;
$rootScope.offsetX1 = 0;
$rootScope.offsetY1 = 0;
$rootScope.x = 0;
$rootScope.y = 0;
$rootScope.mousePressed = false;
$rootScope.lastX; $rootScope.lastY;
$rootScope.rectNumber = 0;
$rootScope.LineNumber = 0;
$rootScope.CircleNumber = 0;
$rootScope.ArrowNumber = 0;
$rootScope.PinNumber = 0;
$rootScope.ObjectIndex = 0;
$rootScope.PinObjectIndex = 0;
$rootScope.TextNumber = 0;
$rootScope.resetTextSave = 0;
$rootScope.ObjectIndexSave = 0;
$rootScope.isLinePreviewCompleted = false;
$rootScope.isArrowPreviewCompleted = false;
$rootScope.isPinPreviewCompleted = false;
$rootScope.isCirclePreviewCompleted = false;
$rootScope.isRectanglePreviewCompleted = false;
$rootScope.isTextAreaPreviewCompleted = false;
var arrayRect = {};
var storeLine = '';
//----
let isDrawing = false;
let currentCanvasId = '';
$scope.onDrawingCanvasOnModule = function (annotationCanvas) {
//remove old event listener
//event code modified .work of only DA,AA,CI,AI,PIC
annotationCanvas.removeEventListener("mousedown", $rootScope.OnPaintCanvasMouseDown);
annotationCanvas.removeEventListener("touchstart", $rootScope.OnPaintCanvasMouseDown);
annotationCanvas.removeEventListener("mouseup", $rootScope.OnPaintCanvasMouseUp);
annotationCanvas.removeEventListener("touchend", $rootScope.OnPaintCanvasMouseUp);
if (annotationCanvas != null || annotationCanvas != undefined) {
annotationCanvas.addEventListener('mousedown', $rootScope.OnPaintCanvasMouseDown);
annotationCanvas.addEventListener("touchstart", $rootScope.OnPaintCanvasMouseDown);
window.addEventListener('mouseup', $rootScope.OnPaintCanvasMouseUp);
window.addEventListener("touchend", $rootScope.OnPaintCanvasMouseUp);
}
}
$scope.removeOnDrawingCanvas = function (annotationCanvas) {
if (annotationCanvas != null || annotationCanvas != undefined) {
//remove old event listener
//event code modified .work of only DA,AA,CI,AI,PIC
annotationCanvas.removeEventListener("mousedown", $rootScope.OnPaintCanvasMouseDown);
annotationCanvas.removeEventListener("touchstart", $rootScope.OnPaintCanvasMouseDown);
annotationCanvas.removeEventListener("mouseup", $rootScope.OnPaintCanvasMouseUp);
annotationCanvas.removeEventListener("touchend", $rootScope.OnPaintCanvasMouseUp);
window.removeEventListener('mouseup', $rootScope.OnPaintCanvasMouseUp);
window.removeEventListener("touchend", $rootScope.OnPaintCanvasMouseUp);
}
}
//Birendra updated due to some issue
$rootScope.OnPaintCanvasMouseDown = function (event) {
event.preventDefault();
if ($rootScope.isAnnotatiomToolBarPopupClosed == false) {
if ($rootScope.shapeType==undefined || $rootScope.shapeType=='cursor'||$rootScope.shapeType=="") {
return;
}
var canvasElement=event.target;
if (canvasElement!= null || canvasElement != undefined)
{
var canvasId = canvasElement.id;
if (canvasId != null ||canvasId != undefined)
{
if(canvasId.match("canvasDA")||canvasId.match("canvasAA")||canvasId.match("canvasCI")||canvasId.match("canvasAI")||canvasId.match("canvasPIC"))
{
var canvasDiv = (event.target.parentElement);
var canvasDivId = canvasDiv.id;
$rootScope.clicked = true;
canvasElement.removeEventListener("mousemove", $rootScope.OnPaintCanvasMouseMove);
canvasElement.removeEventListener("touchstart", $rootScope.OnPaintCanvasMouseMove);
// var ctx = canvasElement.getContext("2d");
$rootScope.offsetX1 = 0;
$rootScope.offsetY1 = 0;
var verticalScrollPosition = canvasDiv.scrollTop;
var horizontlScrollPosition = canvasDiv.scrollLeft;
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
if(event.type == 'touchstart' || event.type == 'touchmove' || event.type == 'touchend' || event.type == 'touchcancel'){
// var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var touch = event.touches[0] || event.changedTouches[0];
var verticalScrollPosition = canvasDiv.scrollTop;
var horizontlScrollPosition = canvasDiv.scrollLeft;
$rootScope.offsetX1 = touch.pageX + horizontlScrollPosition - $('#' + canvasDivId).offset().left;
$rootScope.offsetY1 = touch.pageY + verticalScrollPosition - $('#' + canvasDivId).offset().top;
}
}
else
{
$rootScope.offsetX1 = event.offsetX;
$rootScope.offsetY1 = event.offsetY;
}
// ctx.clearRect(0, 0, 2277, 3248);
canvasElement.addEventListener('mousemove', $rootScope.OnPaintCanvasMouseMove,false);
canvasElement.addEventListener("touchmove", $rootScope.OnPaintCanvasMouseMove,false);
}
}
}
}
}
//Birendra updated due to some issue
$rootScope.OnPaintCanvasMouseUp = function (event) {
event.preventDefault();
if ($rootScope.isAnnotatiomToolBarPopupClosed == false) {
if ($rootScope.shapeType==undefined || $rootScope.shapeType=='cursor'||$rootScope.shapeType=="") {
return;
}
$rootScope.clicked=false;
if (isDrawing === true) {
isDrawing = false;
$(".line").remove();
$(".arrow").remove();
$(".pin").remove();
$(".circle").remove();
$(".rectangle").remove();
$(".textarea").remove();
$rootScope.x = 0;
$rootScope.y = 0;
var canvasElement=event.target;
if (canvasElement != null ||canvasElement != undefined)
{
var canvasId = canvasElement.id;
if(canvasId=="")
{
canvasElement=document.getElementById(currentCanvasId);
canvasId= currentCanvasId;
}
if (canvasId != null ||canvasId != undefined)
{
if(canvasId.match("canvasDA")||canvasId.match("canvasAA")||canvasId.match("canvasCI")||canvasId.match("canvasAI")||canvasId.match("canvasPIC"))
{
var canvasDiv = (canvasElement.parentElement);
var canvasDivId = canvasDiv.id;
// var canvasPaintElement = event.target.previousElementSibling;
canvasElement.removeEventListener('mousemove', $rootScope.OnPaintCanvasMouseMove, false);
canvasElement.removeEventListener("touchmove", $rootScope.OnPaintCanvasMouseMove, false);
var verticalScrollPosition = canvasDiv.scrollTop;
var horizontlScrollPosition = canvasDiv.scrollLeft;
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
if(event.type == 'touchstart' || event.type == 'touchmove' || event.type == 'touchend' || event.type == 'touchcancel'){
// var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var touch = event.touches[0] || event.changedTouches[0];
$rootScope.x = touch.pageX + horizontlScrollPosition - $('#' + canvasDivId).offset().left;
$rootScope.y = touch.pageY + verticalScrollPosition - $('#' + canvasDivId).offset().top;
}
}
else
{
$rootScope.x =Math.round(event.pageX + horizontlScrollPosition - $('#' + canvasDivId).offset().left);
$rootScope.y =Math.round(event.pageY + verticalScrollPosition - $('#' + canvasDivId).offset().top);
}
if($rootScope.shapeType=="Rectangle"|| $rootScope.shapeType=="Circle"|| $rootScope.shapeType=="TextArea")
{
//birendra
// change cordinate when draw in reverse direction
var RectHeight = $rootScope.y - $rootScope.offsetY1;
var RectWidth = $rootScope.x - $rootScope.offsetX1;
var tempx=0;
var tempy=0;
if(RectWidth<0)
{
//swap value
tempx=$rootScope.offsetX1;
$rootScope.offsetX1=$rootScope.x;
$rootScope.x=tempx;
RectWidth = $rootScope.x - $rootScope.offsetX1;
}
if(RectHeight<0)
{
//swap value
tempy=$rootScope.offsetY1;
$rootScope.offsetY1=$rootScope.y;
$rootScope.y=tempy;
RectHeight = $rootScope.y - $rootScope.offsetY1;
}
}
// var ctx = canvasElement.getContext("2d");
// var PaintCanvasctx = canvasPaintElement.getContext("2d");
// activate for unsave curriculum
$rootScope.UnsaveCurriculum = true;
switch ($rootScope.shapeType) {
case "cursor":
// ctx.beginPath();
// PaintCanvasctx.beginPath();
break;
case "Line":
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
$rootScope.LineNumber = $rootScope.ObjectIndex++;
// $rootScope.isLinePreviewCompleted = true;
$rootScope.DrawLineOnModuleItem(canvasId, $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.DrawRectangleOnModuleItem(canvasId, $rootScope.rectNumber, $rootScope.shapestyleFillColor, $rootScope.shapestyleborderColor, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, RectWidth, RectHeight);
break;
case "Circle":
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
$rootScope.CircleNumber = $rootScope.ObjectIndex++;
$rootScope.DrawCircleOnModuleItem(canvasId, $rootScope.CircleNumber, $rootScope.shapestyleOpacity, $rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.shapestyleFillColor, $rootScope.offsetX1, $rootScope.offsetY1, RectWidth, RectHeight);
break;
case "Arrow":
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
$rootScope.ArrowNumber = $rootScope.ObjectIndex++;
$rootScope.DrawArrowOnModuleItem(canvasId, $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.DrawPinOnModuleItem(canvasId, $rootScope.PinNumber,$rootScope.shapestyleborderColor, $rootScope.shapestyleborderWidth, $rootScope.offsetX1, $rootScope.offsetY1, $rootScope.x, $rootScope.y);
break;
case "TextArea":
$rootScope.isAnnotaionToolBarDrawingModeActive = true;
$rootScope.IsTextAlreadySave = false;
$("#text_area").val('');
// Draw text
$rootScope.TextNumber = $rootScope.ObjectIndex++;
var shapestyle={thickness:$rootScope.shapestyleborderWidth,color:$rootScope.shapestyleborderColor,opacity:$rootScope.shapestyleOpacity,fillStyle:$rootScope.shapestyleFillColor};
var textstyle="";
var stringText="";
$rootScope.TextEditorFunctionality(canvasId, $rootScope.TextNumber,stringText,shapestyle,textstyle, $rootScope.offsetX1, $rootScope.offsetY1, RectWidth, RectHeight);
break;
case "DrawPolygon":
break;
}
}
}
}
}
}
}
//Birendra updated due to some issue
$rootScope.OnPaintCanvasMouseMove = function (event) {
event.preventDefault();
isDrawing = false;
currentCanvasId='';
if(!$rootScope.clicked) return;
if ($rootScope.isAnnotatiomToolBarPopupClosed == false) {
if ($rootScope.shapeType==undefined || $rootScope.shapeType=='cursor'||$rootScope.shapeType=="") {
return;
}
if ($rootScope.clicked == true) {
var canvasElement=event.target;
if (canvasElement!= null || canvasElement != undefined)
{
var canvasId = canvasElement.id;
if (canvasId != null ||canvasId != undefined)
{
if(canvasId.match("canvasDA")||canvasId.match("canvasAA")||canvasId.match("canvasCI")||canvasId.match("canvasAI")||canvasId.match("canvasPIC"))
{
var canvasDiv = (event.target.parentElement);
var canvasDivId = canvasDiv.id;
isDrawing = true;
currentCanvasId=canvasId;
var verticalScrollPosition = canvasDiv.scrollTop;
var horizontlScrollPosition = canvasDiv.scrollLeft;
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
if(event.type == 'touchstart' || event.type == 'touchmove' || event.type == 'touchend' || event.type == 'touchcancel'){
// var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var touch = event.touches[0] || event.changedTouches[0];
$rootScope.MouseMoveXAxis = touch.pageX + horizontlScrollPosition - $('#' + canvasDivId).offset().left;
$rootScope.MouseMoveYAxis = touch.pageY + verticalScrollPosition - $('#' + canvasDivId).offset().top;
}
}
else
{
$rootScope.MouseMoveXAxis = event.pageX + horizontlScrollPosition - $('#' + canvasDivId).offset().left;
$rootScope.MouseMoveYAxis = event.pageY + verticalScrollPosition - $('#' + canvasDivId).offset().top;
}
switch ($rootScope.shapeType) {
case "Line":
$(".line").remove();
$rootScope.isLinePreviewCompleted = true;
$("#" + canvasDivId).append("");
$rootScope.Annotationangle();
break;
case "Arrow":
$(".arrow").remove();
$rootScope.isArrowPreviewCompleted = true;
$("#" + canvasDivId).append("");
$rootScope.Annotationangle();
break;
case "Pin":
$(".pin").remove();
$rootScope.isPinPreviewCompleted = true;
$("#" + canvasDivId).append("");
$rootScope.Annotationangle();
break;
case "Circle":
$(".circle").remove();
$rootScope.isCirclePreviewCompleted = true;
$("#" + canvasDivId).append("");
//updated in reverse direction
$rootScope.Annotationangle();
break;
case "Rectangle":
$(".rectangle").remove();
$rootScope.isRectanglePreviewCompleted = true;
$("#" + canvasDivId).append("");
//updated in reverse direction
$rootScope.Annotationangle();
break;
case "TextArea":
$(".textarea").remove();
$rootScope.isTextAreaPreviewCompleted = true;
$("#" + canvasDivId).append("");
//updated in reverse direction
$rootScope.Annotationangle();
break;
}
}
}
}
}
}
}
$rootScope.Annotationangle = function (event) {
var dy = $rootScope.MouseMoveYAxis - $rootScope.offsetY1;
var dx = $rootScope.MouseMoveXAxis - $rootScope.offsetX1;
if($rootScope.shapeType=="Line" ||$rootScope.shapeType=="Arrow" || $rootScope.shapeType=="Pin")
{
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' });
$('.arrowPoint').css({ 'left': 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' });
$('.pinPoint').css({ 'left': dottedLineWidth + 'px' });
break;
case "Circle":
var classname=".circle"
var absheight = Math.abs($rootScope.MouseMoveYAxis - $rootScope.offsetY1);
var abswidth = Math.abs($rootScope.MouseMoveXAxis - $rootScope.offsetX1);
$scope.DrawReverseShape(dx,dy,classname,abswidth,absheight);
break;
case "Rectangle":
var classname=".rectangle"
var absheight = Math.abs($rootScope.MouseMoveYAxis - $rootScope.offsetY1);
var abswidth = Math.abs($rootScope.MouseMoveXAxis - $rootScope.offsetX1);
$scope.DrawReverseShape(dx,dy,classname,abswidth,absheight);
break;
case "TextArea":
var classname=".textarea"
var absheight = Math.abs($rootScope.MouseMoveYAxis - $rootScope.offsetY1);
var abswidth = Math.abs($rootScope.MouseMoveXAxis - $rootScope.offsetX1);
$scope.DrawReverseShape(dx,dy,classname,abswidth,absheight);
break;
}
}
$scope.DrawReverseShape = function (dx,dy,classname,abswidth,absheight){
if(dy < 0 && dx < 0)
{
$(classname).css({'transform': 'rotateZ(' + 180 + 'deg)', '-moz-transform': 'rotateZ(' + 180 + 'deg)', '-webkit-transform': 'rotateZ(' + 180 + 'deg)', 'transform-origin': '0% 0%', 'width': abswidth + 'px','height': absheight + 'px' });
}
else if( dy > 0 && dx > 0)
{
$(classname).css({'transform': 'rotateY(' + 0 + 'deg)', '-moz-transform': 'rotateY(' + 0 + 'deg)', '-webkit-transform': 'rotateY(' + 0 + 'deg)', 'transform-origin': '0% 0%', 'width': abswidth + 'px','height': absheight + 'px' });
}
else if( dx < 0)
{
$(classname).css({'transform': 'rotateY(' + 180 + 'deg)', '-moz-transform': 'rotateY(' + 180 + 'deg)', '-webkit-transform': 'rotateY(' + 180 + 'deg)', 'transform-origin': '0% 0%', 'width': abswidth + 'px','height': absheight + 'px' });
}
else if( dy < 0)
{
$(classname).css({'transform': 'rotateX(' + 180 + 'deg)', '-moz-transform': 'rotateX(' + 180 + 'deg)', '-webkit-transform': 'rotateX(' + 180 + 'deg)', 'transform-origin': '0% 0%', 'width': abswidth + 'px','height': absheight + 'px' });
}
}
$rootScope.onDrawingCanvasClick = function (event) {
if (event != undefined && (event.target.id).match("canvasDA")) {
if ($rootScope.isAnnotaionToolBarDrawingModeActive == false) {
$rootScope.getAnnotationTextBasedOnSelectedBodyRegion(event);
}
}
};
$(document).keydown(function (event) {
// predefined function for detecting keyboard key
if (event.which == 46) {
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasElement = PanelElement.canvasElement;
if (canvasElement == null || canvasElement == undefined) continue;
var canvasId = canvasElement.id;
if ($rootScope.shapeTypePin == "Pin") {
if($rootScope.canvasLayerNameCollection.length>0)
{
if(canvasId==$rootScope.canvasLayerNameCollection[0].panelCanvasId)
{
var shapeName=$rootScope.canvasLayerNameCollection[0].pinName;
$("#" + canvasId).removeLayer(shapeName).drawLayers();
$("#" + canvasId).removeLayer($rootScope.canvasLayerNameCollection[0].ArcName).drawLayers();
$rootScope.shapeTypePin = "";
$rootScope.DeleteShapeWindowData(canvasId,MultiWinId,shapeName);
$rootScope.canvasLayerNameCollection=[];
}
}
}
else if ($rootScope.shapeTypeText == "textAreaRect") {
if($rootScope.canvasLayerNameCollection.length>0)
{
if(canvasId==$rootScope.canvasLayerNameCollection[0].panelCanvasId){
var shapeName=$rootScope.canvasLayerNameCollection[0].textareaRectangle;
$("#" + canvasId).removeLayer(shapeName).drawLayers();
$("#" + canvasId).removeLayer($rootScope.canvasLayerNameCollection[0].textareaString).drawLayers();
$rootScope.shapeTypeText = "";
if (canvasId.match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if(canvasId==$rootScope.jcanvasObjectArray[i].panelCanvasId){
if (shapeName == $rootScope.jcanvasObjectArray[i].name) {
$rootScope.jcanvasObjectArray.splice(i, 1);
}
}
}
}
for (var i = 0; i <= $rootScope.rectDimension.length - 1; i++) {
if(canvasId==$rootScope.rectDimension[i].panelCanvasId){
if (shapeName == $rootScope.rectDimension[i].name) {
$rootScope.rectDimension.splice(i, 1);
$rootScope.textDimension.splice(i, 1);
}
}
}
$rootScope.DeleteShapeWindowData(canvasId,MultiWinId,shapeName);
$rootScope.canvasLayerNameCollection=[];
}
}
}
else {
if($rootScope.canvasLayerNameCollection.length>0)
{
var shapeName=$rootScope.canvasLayerNameCollection[0].name;
if(canvasId==$rootScope.canvasLayerNameCollection[0].panelCanvasId)
{
$("#" + canvasId).removeLayer(shapeName).drawLayers();
if (canvasId.match("canvasAA")) {
for (var i = 0; i <= $rootScope.jcanvasObjectArray.length - 1; i++) {
if(canvasId==$rootScope.jcanvasObjectArray[i].panelCanvasId)
{
if (shapeName == $rootScope.jcanvasObjectArray[i].name) {
$rootScope.jcanvasObjectArray.splice(i, 1);
}
}
}
}
$rootScope.DeleteShapeWindowData(canvasId,MultiWinId,shapeName);
$rootScope.canvasLayerNameCollection=[];
}
}
}
}
}
}
}
});
$rootScope.DeleteShapeWindowData=function(panelCanvasId,MultiWinId,shapeName)
{
if (panelCanvasId.match("canvasDA")) {
var annotationData=$rootScope.GetDAwindowData(MultiWinId,'annotationData');
if(annotationData.shapeStates.length>0)
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.delete().at("layerName == " + shapeName).select();
$rootScope.SetDAwindowData(MultiWinId, 'annotationData', annotationData);
}
}
else if (panelCanvasId.match("canvasAA")) {
var annotationData=$rootScope.GetAAwindowData(MultiWinId,'annotationData');
if(annotationData.shapeStates.length>0)
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.delete().at("layerName == " + shapeName).select();
$rootScope.SetAAwindowData(MultiWinId, 'annotationData', annotationData);
}
}
else if (panelCanvasId.match("canvasCI")) {
var annotationData=$rootScope.GetCIwindowData(MultiWinId,'annotationData');
if(annotationData.shapeStates.length>0)
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.delete().at("layerName == " + shapeName).select();
$rootScope.SetCIwindowData(MultiWinId, 'annotationData', annotationData);
}
}
else if (panelCanvasId.match("canvasAI")) {
var annotationData=$rootScope.GetAIwindowData(MultiWinId,'annotationData');
if(annotationData.shapeStates.length>0)
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.delete().at("layerName == " + shapeName).select();
$rootScope.SetAIwindowData(MultiWinId, 'annotationData', annotationData);
}
}
else if (panelCanvasId.match("canvasPIC")) {
var annotationData=$rootScope.GetPICwindowData(MultiWinId,'annotationData');
if(annotationData.shapeStates.length>0)
{
annotationData.shapeStates = new jinqJs()
.from(annotationData.shapeStates)
.delete().at("layerName == " + shapeName).select();
$rootScope.SetPICwindowData(MultiWinId, 'annotationData', annotationData);
}
}
}
//-- End ----------------------------
$rootScope.AddClick = function (x, y, dragging) {
$rootScope.clickX.push(x);
$rootScope.clickY.push(y);
$rootScope.clickDrag.push(dragging);
}
$rootScope.disableAnnotationTB = false;
$rootScope.disableAnnotationTBFn = function () {
$rootScope.disableAnnotationTB = true;
}
$scope.updateListManagerView = function (panelName) {
$("#listManagerBody *").prop('disabled',false);
$("#listManagerContent *").prop('disabled',true);
$('#AABodySystems').empty();
$('#bodySystems').empty();
$('#termList').empty();
$('#viewName').empty();
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']").not("div[id*='caImagePanel']").not("div[id*='ThreeDImagePanel']").not("div[id*='ciImagePanel']").not("div[id*='aiImagePanel']").not("div[id*='picImagePanel']").not("div[id*='vidImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var i = 0 ; i < modulePanel.length; i++) {
var paneld = modulePanel[i].id;
var panelTitle = document.getElementById(paneld).childNodes[0].innerText;
$('#viewName').append('');
}
$("#viewName").val(modulePanel[0].id).change();
}
else
{
$rootScope.CloseListManager();
}
}
$rootScope.disableAnnotationtoolOnListManager = false;
$rootScope.ShowListManager = function () {
$("#listManagerContent *").prop('disabled',true);
$('#AABodySystems').empty();
$('#bodySystems').empty();
$('#termList').empty();
$('#viewName').empty();
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']").not("div[id*='caImagePanel']").not("div[id*='ThreeDImagePanel']").not("div[id*='ciImagePanel']").not("div[id*='aiImagePanel']").not("div[id*='labImagePanel']").not("div[id*='picImagePanel']").not("div[id*='vidImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
var panelTitle = document.getElementById(paneld).childNodes[0].innerText;
$('#viewName').append('');
}
}
$('#listManager').css('display', 'block');
$("#listManager").css("visibility", "visible");
// register event for search list manager
$(document).on("mouseover", "#termList option", function (e) {
$('#termList option[selected="selected"]').attr("selected", false);
$(this).attr("selected", true);
});
$("#termList").unbind('keyup');
$("#termList").on('keyup', function (event) {
$('#termList option[selected="selected"]').attr("selected", false);
$(this.selectedOptions[0]).attr("selected", true);
});
$("#termList").unbind('keypress');
$("#termList").on('keypress', function (e) {
if ($('#termList option[selected="selected"]').attr("id") == "undefined") {
return false;
}
else {
if ($('#termList option[selected="selected"]').attr("id")) {
if (e.keyCode == 13) {
var selectedPanel = $("#viewName option:selected").val();
if(selectedPanel.match("daImagePanel"))
{
onListManagerTermSelection($('#termList option[selected="selected"]').attr("id"),true);
}
else if(selectedPanel.match("AAImagePanel"))
{
onSearchItemSelection($('#termList option[selected="selected"]').attr("id"));
}
}
}
}
});
if(modulePanel.length>0)
{
$("#viewName").val(modulePanel[0].id).change();
}
}
$rootScope.changeListManager = function () {
$rootScope.isLoading = true;
$('#spinner').css('visibility', 'visible');
$('#AABodySystems').empty();
$('#bodySystems').empty();
$('#termList').empty();
$timeout(function () {
var selectedPanel = $("#viewName option:selected").val();
if(selectedPanel!="0" && selectedPanel!=undefined)
{
$rootScope.loadViewListManager(selectedPanel);
}
},100);
}
$rootScope.loadViewListManager = function (selectedPanel) {
var windowviewid=selectedPanel.split('_')[1];
$("#listManagerContent *").prop('disabled',false);
$("#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.islistManagerEventAlredayDispachted = true;
if(selectedPanel.match("daImagePanel"))
{
$rootScope.dalistManagerEvent(windowviewid);
$("#termList").attr("onclick", "if (typeof(this.selectedIndex) != 'undefined') onListManagerTermSelection(this.options[this.selectedIndex].id, true)");
}
else if(selectedPanel.match("AAImagePanel"))
{
$rootScope.aalistManagerEvent(windowviewid);
$("#termList").attr("onclick", "if (typeof(this.selectedIndex) != 'undefined') onSearchItemSelection(this.options[this.selectedIndex].id)");
}
var modulePanel = $("#HomeContainerDiv").find("div[id*='daImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel"))
{
$rootScope.switchCanvas(paneld);
}
}
}
}
$rootScope.CloseListManager = function () {
$('#listManager').css('display', 'none');
$("#listManager").css("visibility", "hidden");
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel")||paneld.match("AAImagePanel")||paneld.match("ciImagePanel")||paneld.match("aiImagePanel")||paneld.match("picImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
var PanelElement= $scope.GetPanelElement(paneld);
var canvasPaintElement = PanelElement.canvasPaintElement;
if (canvasPaintElement == null || canvasPaintElement == undefined) continue;
var canvasPaintId = canvasPaintElement.id;
if (paneld.match("daImagePanel")) {
$("#btnTranparency_" + MultiWinId).removeAttr('disabled', 'disabled');
}
$rootScope.isListManagerMenuSelected = false;
console.log('listManager closed');
$rootScope.disableAnnotationtoolOnListManager = false;
if (paneld.match("daImagePanel") || paneld.match("AAImagePanel")) {
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(paneld);
}
}
}
}
}
}
$rootScope.isLoading = false;
$('#spinner').css('visibility', 'hidden');
}
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;
if (navigator.userAgent.match(/(iPod|iPhone|iPad|android)/i)) {
$("#modal-settings").draggable('disable');
}
};
$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;
$("#modon").prop("checked", true);
$("#modoff").prop("checked", false);
}
else {
$rootScope.isModestyOn = false;
$rootScope.isModestyOff = true;
$("#modon").prop("checked", false);
$("#modoff").prop("checked", 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) {
if ($rootScope.isCloseSettingClicked == true) {
formsetting.ethnicity = localStorage.getItem("globalEthnicity");
$rootScope.isCloseSettingClicked = false;
}
else {
formsetting.ethnicity = skintone;
}
$rootScope.setEthncitySettings(formsetting.ethnicity);
}
$rootScope.ChangeModesty = function (modestyValue) {
//formsetting.modesty = modestyValue;
$rootScope.setModestySettings(modestyValue);
//code for modesty setting
$rootScope.formsetting.modesty = modestyValue;
$rootScope.aiaModesty = $rootScope.formsetting.modesty;
}
$rootScope.isApplyBtnClicked = false;
$rootScope.CancelSetting = function () {
$rootScope.isCloseSettingClicked = true;
$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.CloseSetting = function () {
if($rootScope.isApplyBtnClicked)
{
$("#saveSettingsMessageModal").modal('show');
$("#saveSettingsMessageModal").css('zIndex', 80000000000);
}
else
{
$rootScope.CancelSetting ();
}
}
$rootScope.saveSettings = function () {
var currentSkintone = $rootScope.globalSetting.ethnicity;
var currentModesty = $rootScope.globalSetting.modesty;
var setting={};
setting.modesty =currentModesty ;
setting.skintone = currentSkintone;
setting.userId = $rootScope.userData.Id;
AuthenticationService.saveSetings(setting)
.then(
function (result) {
var k= result;
if(result==1){
$('#modal-settings').css("display", "none");
$("#modelsettingsbackground").css("display", "none");
//hide saveSettingsMessageModal
$("#saveSettingsMessageModal").modal('hide');
$rootScope.sucessMessage = AIAConstants.SETTINGS_SAVED
$("#successMessageModal").modal('show');
}
else
{
$rootScope.errorMessage =AIAConstants.SETTING_SAVE_ERROR;
$("#messageModal").modal('show');
}
}),
function (error) {
console.log(' Error in Saving settings = ' + error.statusText);
$rootScope.isVisibleLogin = true;
$rootScope.errorMessage = error;
$("#messageModal").modal('show');
}
}
$rootScope.UpdateAndCloseSetting = function (setting) {
$rootScope.UpdateSetting(setting);
$rootScope.isApplyBtnClicked = false;
$('#modal-settings').css("display", "none");
$("#modelsettingsbackground").css("display", "none");
$rootScope.lexiconLanguageArrayLength = $rootScope.lexiconLanguageArray.length;
};
$rootScope.deSelectLanguageOptions = function () {
var languageDifference = ($rootScope.lexiconLanguageArrayLength) - ($rootScope.lexiconLanguageArray.length);
languageDifference = parseInt(languageDifference);
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();
}
if ($rootScope.lexiconPrimaryLanguage == $("#primarylaxican").val()) {
}
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);
}
}
else if (languageDifference == 0) {
if ($rootScope.lexiconPrimaryLanguage == $("#primarylaxican").val()) {
}
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);
}
}
$('#lexiconLangDropdown').html($('#lexiconLangDropdown').find('option').sort(function (x, y) {
return $(x).text() > $(y).text() ? 1 : -1
}));
}
$rootScope.UpdateSetting = function (setting) {
$rootScope.isCallFromOtherModule = undefined;
$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.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");
// change DA setting for single/multiple panel
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
if ($('.modestyImg_' + MultiWinId) != null) {
if (($rootScope.globalSetting.modesty == 'Y')) {
$('.modestyImg_' + MultiWinId).css('visibility', 'visible');
}
else {
$('.modestyImg_' + MultiWinId).css('visibility', 'hidden');
}
}
if ($('.transModestyImg_' + MultiWinId) != null) {
if (($rootScope.globalSetting.modesty == 'Y')) {
$('.transModestyImg_' + MultiWinId).css('visibility', 'visible');
}
else {
$('.transModestyImg_' + MultiWinId).css('visibility', 'hidden');
}
}
if ($rootScope.isLayerLessSeven == true) {
if (($rootScope.globalSetting.modesty == 'Y')) {
$('.modestyImg_' + MultiWinId).css('visibility', 'visible');
}
}
else {
$('.modestyImg_' + MultiWinId).css('visibility', 'hidden');
}
if ($rootScope.isTBLayerLessSeven == true) {
if (($rootScope.globalSetting.modesty == 'Y')) {
$('.transModestyImg_' + MultiWinId).css('visibility', 'visible');
}
}
else {
$('.transModestyImg_' + MultiWinId).css('visibility', 'hidden');
}
$rootScope.changeNavigatorModesty(MultiWinId);
}
}
}
}
if (isReloadingViewRequired == true) {
$rootScope.reloadChildController();
}
$rootScope.lexiconRemovedLanguage = [];
$("#secondLax option").each(function () {
$rootScope.lexiconRemovedLanguage.push({ "id": $(this).attr("val"), "language": $(this).val() });
});
};
$rootScope.reloadChildController = function () {
// change DA setting for single/multiple panel
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']");
if (modulePanel != undefined && modulePanel.length>0) {
for (var index = 0 ; index < modulePanel.length; index++) {
var paneld = modulePanel[index].id;
if(paneld.match("daImagePanel"))
{
var len = (paneld).split("_").length;
var MultiWinId = (paneld).split("_")[len - 1];
$rootScope.isSettingEventAlredayDispachted = true;
var currentOpenViewId=$rootScope.GetDAwindowData(MultiWinId,"voId");
$rootScope.reloadDABodyViewEvent(currentOpenViewId,MultiWinId);
}
}
}
};
$rootScope.changeNavigatorModesty = function (MultiWinId) {
var currentOpenViewId=$rootScope.GetDAwindowData(MultiWinId,"voId");
$rootScope.changeNavigatorModestyEvent(currentOpenViewId,MultiWinId);
};
$rootScope.ShowExportImageWindow = function () {
var userid = $rootScope.userData.Id;
var isExportedImage = $scope.GetUserExportImageData(userid, 'isExportImage');
if (isExportedImage) {
var $ua = navigator.userAgent;
if (($ua.match(/(iPod|iPhone|iPad|android)/i))) {
$(".export-image-ipad").modal("show").draggable({ handle: ".modal-header" });
$(".modal-backdrop").css("opacity", ".5");
$(".modal-backdrop").css("z-index", "1200001");
}
else
{
$(".export-image").modal("show").draggable({ handle: ".modal-header" });
$(".modal-backdrop").css("opacity", ".5");
$(".modal-backdrop").css("z-index", "1200001");
}
}
else {
var exptAlertMessage = $scope.GetUserExportImageData(userid, 'LimitOverMessage');
$(".export-image-message").modal("show").draggable({ handle: ".modal-header" });
$(".modal-backdrop").css("opacity", ".5");
$(".modal-backdrop").css("z-index", "1200001");
document.getElementById("expMessage").innerHTML = exptAlertMessage;
}
};
$rootScope.ShowPrintWindow = function () { // Print Active Viewer
if ($('#printDivContent').html() != "") {
$('#printDivContent').empty();
}
var PanelElement= $scope.GetPanelElement($rootScope.panelNameWithCb);
// selected panel
var panelTitle = document.getElementById($rootScope.panelNameWithCb).childNodes[0].innerText;
var canvasDivElement = PanelElement.canvasDivElement;
if (canvasDivElement == null || canvasDivElement == undefined) return;
var canvasDivId = canvasDivElement.id;
CollectPrintData(canvasDivId, 1, panelTitle);
$timeout(function () {
SetFrameToPrint();
}, 500);
};
$rootScope.ShowAllPrintWindow = function () {
if ($('#printDivContent').html() != "") {
$('#printDivContent').empty();
}
var multiprint = function (canvasId, page, title, delaytime) {
$timeout(function () { CollectPrintData(canvasId, page, title) }, delaytime);
};
var pageno = 0;
// select all open module div.
var modulePanel = $("#HomeContainerDiv").find("div[id*='ImagePanel']").not("div[id*='caImagePanel']").not("div[id*='ThreeDImagePanel']").not("div[id*='labImagePanel']").not("div[id*='vidImagePanel']");
for (var i = 0 ; i < modulePanel.length; i++) {
var paneld = modulePanel[i].id;
var PanelElement= $scope.GetPanelElement(paneld);
var canvasDivElement = PanelElement.canvasDivElement;
if (canvasDivElement == null || canvasDivElement == undefined) return;
var canvasDivId = canvasDivElement.id;
var panelTitle = document.getElementById(paneld).childNodes[0].innerText;
var timeintrval = pageno * 400;
multiprint(canvasDivId, pageno, panelTitle,timeintrval);
if(pageno==modulePanel.length-1)
{
$timeout(function () {
// working for all device
SetFrameToPrint();
}, pageno * 400+500);
}
pageno = pageno + 1;
}
}
function CollectPrintData(canvasDivId, pageno, panelTitle) {
// Birendra
// create page to store print image data for all devices
html2canvas($("#" + canvasDivId), {
onrendered: function (canvas) {
var dataURL = canvas.toDataURL("image/jpeg");
if (pageno == 1) {
$('#printDivContent').append("");
}
else {
$('#printDivContent').append("
");
}
$('#dvPortrait' + pageno).append("
");
$('#image_preview' + pageno).append("